I apologize if this question is stupid or duplicated, please point me to the right direction if so.
I've tested this code:
function b()
{
a: 22;
return a;
}
Code returns no error. Which leads me into thinking a: 20 inside function works. Though when call the function:
b();
..I receive "ReferenceError: a is not defined"
What does a: 22 inside function actually do? this.a inside function returns nothing so I don't think it has something to do with function as object (or it does?..)
The a: 22 in your code is a label – it labels the statement 22 with the identifier a.
From MDN:
The labeled statement can be used with break or continue statements. It is prefixing a statement with an identifier which you can refer to.
Read more here: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/label
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With