最近在学习javascript,然后发现hao123的源码里有
currentProfile = {"urls":"false","skin":"skin-color-green","HAOTOPLIST_NEW":"top2_topmsg","navigate":"0"},
defaultProfile = {"urls":"false","skin":"skin-color-green","HAOTOPLIST_NEW":"top2_topmsg","navigate":"0"},
我的疑问是:对象的属性为什么加了“”?
不是应该是currentProfile={urls:"false",skin:"skin-color-green",HAOTOPLIST_NEW:"top2_topmsg",navigate:"0"}吗?对象JavaScript引号
currentProfile = {"urls":"false","skin":"skin-color-green","HAOTOPLIST_NEW":"top2_topmsg","navigate":"0"},
defaultProfile = {"urls":"false","skin":"skin-color-green","HAOTOPLIST_NEW":"top2_topmsg","navigate":"0"},
我的疑问是:对象的属性为什么加了“”?
不是应该是currentProfile={urls:"false",skin:"skin-color-green",HAOTOPLIST_NEW:"top2_topmsg",navigate:"0"}吗?对象JavaScript引号
alert(eval('{foo:"bar"}')); // return "bar", incorrect
在不加引号时这个返回的是bar,而不是一个json对象。alert(eval('({"foo": "bar"})')); // return JSON object, correct
比如下面的都要加“”
obj = { "class":"asd", "201":"asd", "code-javascript":"asd", "我是属性名称":"asd", "0egg":"asd", "$&":"asd" };