Skip to content

JS遍历数组

使用prototype

[javascript]

var str = [“a”,”b”];Array.prototype.f=function(){}
for(var key in str){

console.log(key + “::” + (str[key] + “”));
}
// 0::a VM349:4
// 1::b VM349:4
// f::function (){}

[/javascript]

遍历数组

[javascript]

for(var key in str){

console.log(key + “::” + (str[key] + “”));

}

for(var key=0;key<str.lengh;key++){

console.log(key + “::” + (str[key] + “”));

}

[/javascript]

领支付宝红包:打开支付宝搜索 726845401

领饿了么红包:0fυィ直文本 e:/$XGzEgR8$~.👉饿了么App👈【快來領外賣紅包,最高20元,人人都有哦~】

 

您的赞助将会鼓励作者技术文章创作以及支持本站运维。

发表评论

Your email is never published nor shared. Required fields are marked *


TOP