The difference between x-- and --x: 1. [--x] decrements the value of x by 1 first, and then calculates the value of x; 2. [x--] calculates x first value, and then decrement the value of x by 1.
##The difference between x-- and --x:
- -x
means that the value of x is decremented by 1 first, and then the value of x is calculated.
x--
is to first calculate the value of x, and then decrement the value of x by 1.
var x = 10; console.log(x--); console.log(x);Output:
10 9The first output is 10, x--first use the value of x in the current expression , and then decrement the value of x by 1; the second output is 9, because x has decremented by 1 after the previous instruction. Example 2:
var x = 10; console.log(--x); console.log(x);Output:
9 9The first output is 9, --x first decrements the value of x by 1, and then in the current expression Use the value of x; the second one also outputs 9, and x has been decremented by 1 after the previous instruction.
The above is the detailed content of What is the difference between x-- and --x. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Dreamweaver Mac version
Visual web development tools

WebStorm Mac version
Useful JavaScript development tools

Zend Studio 13.0.1
Powerful PHP integrated development environment