console.log(b=1) // 1
Because assignment has a return value, we are able to chain assignments.
let a;
let b;
a = b = 1
console.log(a); // 1
console.log(b); // 1
Hard to read, but it works...
let a = 1;
let b = 2;
let c = 3 - (a = b + 1);
console.log(a); // 3
console.log(c); // 0
Top comments (1)
I think it's for REPL, so it will show the final result for assignment as well