Javascript Arithmetic Operator Question 5

Introduction

What is the output of the following code:


let x = 10;//w  w  w  .ja  v  a  2 s .com
let y = ++x;    // y becomes 11, and x becomes 11 too.
console.log(x);
console.log(y);
y = x++;    // y is still 11, but x has become 12.
console.log(x);
console.log(y);
y = --x;    // y is still 11, and so is x now.
console.log(x);
console.log(y);
y = x--;    // y is still 11, but x is now 10.
console.log(x);
console.log(y);


11
11
12
11
11
11
10
11



PreviousNext

Related