How to use decrement (--) operator in JavaScript

2 Answers

0 votes
let x = 5;
const y = x--;

console.log(`x = ${x}, y = ${y}`);




/*
run:

"x = 4, y = 5"

*/

 



answered Nov 13, 2020 by avibootz
0 votes
let x = 5;
const y = --x;

console.log(`x = ${x}, y = ${y}`);




/*
run:

"x = 4, y = 4"

*/

 



answered Nov 13, 2020 by avibootz

Related questions

...