On objects / JSON we use :
for keys and values, for example:
{x: 1}
As discussed in What is the use of the colon in JavaScript?
However, I was working on a small script to try to detect the JSON format before parse to avoid many possible try / catch I would perhaps need to do and I came across this:
foo:console.log([1, 2, 3]);
Note that this is 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 think the error message is "Labels" , so how and when can we use Labels in JavaScript? Is there any detail that differentiates the Label in JS from other languages?