Your Web News in One Place

Help Webnuz

Referal links:

Sign up for GreenGeeks web hosting
November 24, 2021 08:47 pm GMT

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:    Share on Facebook
View Full Article

Dev To

An online community for sharing and discovering great ideas, having debates, and making friends

More About this Source Visit Dev To