gpt4 book ai didi

javascript - Array.each 输出所有方法

转载 作者:行者123 更新时间:2023-11-28 14:05:22 24 4
gpt4 key购买 nike

为什么会...

for(var k in this.errors) {
$('error_list').insert({
bottom: new Element('li').update(k + ' :'+this.errors[k])
})
}

...输出放置所有 Prototype 可枚举方法,以及我添加到数组中的内容?

我正在构建一个关联数组:

this.errors['email'] = 'Your email is invalid';

最佳答案

您可以使用hasOwnProperty来阻止这种情况:

for(var k in this.errors) {
if (this.errors.hasOwnProperty(k)) {
$('error_list').insert({
bottom: new Element('li').update(k + ' :'+this.errors[k])
})
}
}

关于javascript - Array.each 输出所有方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1791281/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com