I knew that {}
is either an object or a block of code, but today my co-worker asked me why {foo: 1}
works when entered into the console, but
{}
not block always, you can make an object with it (JSON style)
for example
var objectName = {
propertyName:"Fiat",
model:500,
color:"white",
methodName:function(a) {
return a;
}
};
objectName.methodName('aa');
objectName.propertyName
objectName[propertyName]
and they're blocks
if(...){ .. }
while(...) { ... }
try(..) { ...} catch { ...}