Hi all,
Is there any difference between:
and:Code:var object = { name : "value" };
?Code:var object = { "name" : "value" };
Thanks!
Hi all,
Is there any difference between:
and:Code:var object = { name : "value" };
?Code:var object = { "name" : "value" };
Thanks!
No — but an unquoted name must be a valid identifier.
Code:// These are equivalent: ({ foo: 5 }); ({ 'foo' : 5 }); // But these are legal: ({ '1st' : 3 }); ({ 'class' : 5 }); ({ 'foo-bar' : 10 }); // While these are illegal: ({ 1st: 3 }); ({ class: 5 }); ({ foo-bar: 10 });
Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!
jlizarraga (03-12-2009)
Well the first is a more common practice, the second is more like defining array keys: var t=new Array("hi"=>5);, which is actually an object.
[Jasme Library (Javascript Motion Effects)] My Site
/\/\@§†ê® §©®¡þ† /\/\@|{ê®
There are 10 kinds of people in the world, those that understand binary and those that don't.
jlizarraga (03-12-2009)
Bookmarks