[Javascript] ++operation

What's the output of following code:

let a = 1;
const b = a + ++a * a++;

 

In Javascript, the code always run from lef to right.

Both ++aand a++ are expression. Every expression has return value.

a++returns 1, then a was assigned to 2

let a = 1;
const b = a + ++a * a++;
// const b = 1 + 2 * 2
// let a = 3

 

posted @ 2024-11-24 19:29  Zhentiw  阅读(8)  评论(0)    收藏  举报