Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
256 views
in Technique[技术] by (71.8m points)

I don't understand they outputs of this increment example

i found this example online of the pre and post fix examples of incrementing and decrementing a variable. however, i don't understand why it is return x as 4 and subsequently a as 4 in the example. I understand the y values.

let x = 3;
const y = x++;

console.log(x:${x}, y:${y});
// expected output: "x:4, y:3"

let a = 3;
const b = ++a;

console.log(a:${a}, b:${b});
// expected output: "a:4, b:4"

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...