String For Field Name In Javascript Object Literals
I have a question regarding field names in js object literals. I have a function test that looks like this: function test() { var o1 = {f1:'Hello'}; var o2 = {'f1':'Hello'}
My question is, what is the difference between the two objects?
They are identical.
Is there a difference between quoting the field name and not?
Quoted property names can be things which are not valid identifiers.
e.g. { "foo-bar": 1 }
is fine but { foo-bar: 1 }
is a syntax error.
Post a Comment for "String For Field Name In Javascript Object Literals"