javascript - 如何在没有循环的情况下验证哈希表中包含的值?例如:
var a = new Object(); // or just []
a[0] = 0
a['one'] = 1;
a['two'] = 2;
a['three'] = 3;
javascript - 如何在没有循环的情况下验证哈希表中包含的值?例如:
var a = new Object(); // or just []
a[0] = 0
a['one'] = 1;
a['two'] = 2;
a['three'] = 3;
您可以使用hasOwnProperty
var hash = new Object(); // or just {}
hash['one'] = 1;
hash['two'] = 2;
hash['three'] = 3;
if (hash.hasOwnProperty(k)) {
alert('Has')
}
试试 jQuery
$(hashtablename).each(function (item) {
//code to verify.
});
虽然在内部它仍然会使用循环..