9
In objects/JSON we use :
for keys and values, for example:
{x: 1}
As discussed in How to use the two points in Javascript?
However, I was working on a small script to try to detect the JSON format before the parse to avoid many Try/catch possible that I might need to maybe do and I came across this:
foo:console.log([1, 2, 3]);
Note that it’s not an object, so I tested this:
foo:foo:console.log([1, 2, 3]);
It returns the error:
"Uncaught Syntaxerror: Label 'foo' has already been declared",
I believe by the error message this is "Labels", then how and when we can use Javascript Labels? Is there any detail that differentiates the JS Label from other languages?
tip: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/label
– Guilherme Nascimento