What is the difference between this
var person = {
name: "Bob",
age: "99"
};
and this?
var person = {
"name": "Bob",
"age": "99"
};
Or do they mean the same thing? If they do, what if I want the key to be an object? How would I specify the object as the key if name means "name"?
"object"is a perfectly valid property name."object"is not a valid property name? I don't even sayx = {object: "foo"};is invalid! It is valid but the keyobjectofxis converted implicitly to string"object"and has nothing to do withobjectfrom global namespace. Misleading? Yes, using keys likeobjector"object"is misleading, confusing etc. And don't try to tell me that string is an object too. I know that. The main thing is that whatever the key is, it will be converted to string if it isn't string already. No way to have "object key" with custom methods and attrs.