开发者

javascript object instantiation to include an array as one of the properties

I am trying to create an object which includes an array stPoints as one of its properties. I am getting an error message saying that stPoints is undefine开发者_JS百科d. What is the proper way to declare an array property within an object?

this is my code:

var temp={stName:"#states.stateid#",stPoints:[]};


This is correct. You must be referencing it incorrectly.

temp.stPoints


var temp={ 'stName':"#states.stateid#", 'stPoints':[] };

However, if the property name is a valid javascript identifier, as in this case, you should not have problem.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜