Mootools 对象内的跳转迭代。each()
如果满足条件,是否有方法在Mootools 对象内的跳转迭代。each(),mootools,Mootools,如果满足条件,是否有方法在对象内跳转当前迭代。each() 我可以使用: Object.each(myObject, function(item, key){ if(key != 'someString'){ //do everything } }); 但是我想要像这样的东西 Object.each(myObject, function(item, key){ if(key == 'someString') continue; }); 您可以为对象添加
对象内跳转当前迭代。each()
我可以使用:
Object.each(myObject, function(item, key){
if(key != 'someString'){
//do everything
}
});
但是我想要像这样的东西
Object.each(myObject, function(item, key){
if(key == 'someString') continue;
});
您可以为对象添加与数组相同的内容 顺便说一句,我希望你的问题是关于休息的,对吗?不
继续
因为要继续
,您需要做的就是从对象的回调函数fn中提前返回
Object.each(myObject, function(item, key){
if(key == 'someString') return;
// code here will run only if key is somethingelse.
});
无论如何,实现Object.every和Object.some(不是在proto上,只是托管在Object上)
以下是一些用途:
var foo = {
one: 1,
two: 2,
bar: 'haha',
three: 3
};
// loop keys until the key is bar then stop.
Object.some(foo, function(value, key){
console.log(key, value);
return key === 'bar';
});
// loop keys until a non-number is encountered, then stop
Object.every(foo, function(value, key){
console.log(key, value);
return typeof value === 'number';
});
您可以为对象添加与数组相同的内容
顺便说一句,我希望你的问题是关于休息的,对吗?不继续
因为要继续
,您需要做的就是从对象的回调函数fn中提前返回
Object.each(myObject, function(item, key){
if(key == 'someString') return;
// code here will run only if key is somethingelse.
});
无论如何,实现Object.every和Object.some(不是在proto上,只是托管在Object上)
以下是一些用途:
var foo = {
one: 1,
two: 2,
bar: 'haha',
three: 3
};
// loop keys until the key is bar then stop.
Object.some(foo, function(value, key){
console.log(key, value);
return key === 'bar';
});
// loop keys until a non-number is encountered, then stop
Object.every(foo, function(value, key){
console.log(key, value);
return typeof value === 'number';
});
嘿,像数组。一些对象的?我知道它是激进的,但您是否考虑过对(myObject中的键){}
循环使用正常的?仍然是javascript:)请参阅答案。Object.some/Object.every。与数组中的行为相同。它甚至在lodash/下划线中都不可用,this.heh,比如数组。一些对象的?我知道它是激进的,但您是否考虑过对(myObject中的键){}
循环使用正常的?仍然是javascript:)请参阅答案。Object.some/Object.every。与数组中的行为相同。我的问题是关于继续
,我的无知使我无法尝试返回
,因此感谢您的解决方案!扩展对象以使其具有一些
和每个
的简便方法。我想听听你的意见/建议,回到基本点,使用一个很好的for循环:,这也很好用。非常感谢。嗯,我的问题是关于继续
,我的无知使我无法尝试返回
,所以感谢您的解决方案!扩展对象以使其具有一些
和每个
的简便方法。我想听听你的意见/建议,回到基本点,使用一个很好的for循环:,这也很好用。非常感谢。