The {} is a code block with a value of 1 inside. It has nothing to do with Addition operator outside of it. When parser reads this line it will evaluate 1 and move to another expression, which is + 0, and will output 0.
{// this is a blockleta=10;console.log(a)// prints 10 letb=30;}// This is outside of the blockleta=20;console.log(a);// prints 20console.log(b);// throws a ReferenceError
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Hi Milindu,
The
{}is a code block with a value of1inside. It has nothing to do withAddition operatoroutside of it. When parser reads this line it will evaluate1and move to another expression, which is+ 0, and will output0.