Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

-1 in javascript



let c = 0;

console.log(c + 1); // outputs 1

console.log(c); outputs 0, since in the last statement you didn't changed the original value, just used it.

console.log(c++); // will output c then increment c. So it prints the old value: 0

console log(c); will output 1 (result of previous increment)

console.log(++c); // will increment c and then output it new value: 2


Source by nullorempty.org #
 
PREVIOUS NEXT
Tagged: #javascript
ADD COMMENT
Topic
Name
1+9 =