I'm reading an article that says that {} is a valid JavaScript program.
I tried it and it worked fine.
Then I tried this and it worked:
{name:'Lord Stark'} <--- the entire program (not assigning it to a variable or anything)
But then I tried the following and it threw an error at the comma.
{name:'Lord Stark',reignsOver:'Winterfell'} <--- again this is the entire program
My question is, why does a plain object with more than one property (and consequently a comma), return an error unless assigned to a variable when an object with only a single entry does not?
{name:'Lord Stark'}is"Lord Stark", not{name: "Lord Stark"}.{}is a valid JavaScript program. It says that{}is a JavaScript object literal, but an object literal is not a program.