关于each()方法的一种使用
2019-07-10 本文已影响0人
白云若水
//判断有没有设置 'pull', 'put' 如果没有 则添加 'pull', 'put' 属性并且设置为真
['pull', 'put'].forEach(function(key) {
if (!(key in group)) { //
group[key] = true; //将为group对象添加两个属性'pull', 'put' 并且为true
}
});
//判断有没有设置 'pull', 'put' 如果没有 则添加 'pull', 'put' 属性并且设置为真
['pull', 'put'].forEach(function(key) {
if (!(key in group)) { //
group[key] = true; //将为group对象添加两个属性'pull', 'put' 并且为true
}
});