Skip to content

JavaScript 中对像的 “foreach” 语法

//变量声明,方法一:假如 Object 未被扩展

var array = new Object();

//变量声明,方法二:假如 Object 已被扩展

var array;


array[‘something’] = ‘yay’;
array[‘somethingelse’] = ‘more’;


for ( var keyVar in array ) {

注意 var keyVar ,不加var 为全局全量,可能引起冲突

Posted in JavaScript/DOM/XML, 技术.

No Responses (yet)

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.

Some HTML is OK

or, reply to this post via trackback.