I am reading an article that says it {}is a valid JavaScript program.
I tried and it worked fine.
Then I tried this and it worked:
{name:'Lord Stark'} <--- the whole program (without assigning it to a variable or something)
But then I tried the following, and he introduced the error into a comma.
{name:'Lord Stark',reignsOver:'Winterfell'} <--- again this is the whole program
My question is: why does a simple object with more than one property (and therefore a comma) return an error if it is not assigned to a variable, if an object with only one record does not work?
source
share