What is the weird error in JS formatting a new object?

My javascript code that generates a syntax error:

var x =
{
  a: 123
};

The same code without errors:

var x = {
  a: 123
};

What the hell?

+3
source share
1 answer

Javascript adds implicit ";" at the end of lines sometimes, I suppose this is what happens and leads to

var x = ;
+2
source

Source: https://habr.com/ru/post/1753038/


All Articles