A small question:
In my Browser(GoogleChrome) console if I type
abc:xyz:123
it evaluates to
123
How does JavaScript evaluate :
?
Both abc
and xyz
are treated as loop labels. Quoting from MDN,
Provides a statement with an identifier that you can refer to using a break or continue statement.
For example, you can use a label to identify a loop, and then use the break or continue statements to indicate whether a program should interrupt the loop or continue its execution.
Also, check Avoid using labels section,
Labels are not very commonly used in JavaScript since they make programs harder to read and understand. As much as possible, avoid using labels and, depending on the cases, prefer calling functions or throwing an error.
I believe what is happing is abc
and xyz
are being treated as labels. So 2 labels are being created and then the statement of 123
is being evaluated which gives you the result of 123
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