An Interest In:
Web News this Week
- March 20, 2024
- March 19, 2024
- March 18, 2024
- March 17, 2024
- March 16, 2024
- March 15, 2024
- March 14, 2024
Some of Our Sources
View All Sources
November 24, 2021 08:47 pm GMT
Original Link: https://dev.to/icncsx/assignment-has-a-return-value-in-js-2359
Assignment has a return value in JS
console.log(b=1) // 1
Because assignment has a return value, we are able to chain assignments.
let a;let b;a = b = 1console.log(a); // 1console.log(b); // 1
Hard to read, but it works...
let a = 1;let b = 2;let c = 3 - (a = b + 1);console.log(a); // 3console.log(c); // 0
Original Link: https://dev.to/icncsx/assignment-has-a-return-value-in-js-2359
Share this article:
Tweet
View Full Article
Dev To
An online community for sharing and discovering great ideas, having debates, and making friendsMore About this Source Visit Dev To