使用以下代码将值推送到JSON数组
var schedule = [];
myArray = [ { Tests: [ [Object] ],
_id: '52bd60d72270a398d3f87302',
browser: [ 'FF' ],
id: '71',
mode: 'weekly',
os: 'VM-WIN7-64',
server: '172.16.2.120' },
{ Tests: [ [Object], [Object] ],
_id: '52c247f1cf0060b8cce84b42',
browser: [ 'FF' ],
id: '45',
mode: 'daily',
os: 'VM-WIN7-64',
server: '172.16.2.120' },
{ _id: '52ca2b0dafcec877d925d111',
Tests: [ [Object], [Object], [Object] ],
browser: [ 'FF', 'IE' ],
id: '37',
mode: 'daily',
os: 'VM-WIN7-32',
server: '172.16.2.120' } ];
第一次调用execute
时,myArray包含1个值。我必须根据myArray
值调用执行函数。如果它包含4个值,它将调用四次,就像明智一样。并附加{ {1}}值来调度执行函数内的数组
myArray
我在execute(myArray ){
schedule.push(myArray );
}
函数中要做的就是相互检查execute
值并检测它们是否相等?如果相等,我必须执行其他任务其他任务如何有可能吗?
答案 0 :(得分:1)
myArray
被错误地表示为string
数据类型。所以删除“quotes
。
execute(myArray ){
$.each(myArray, function(index, value) {
//now you have access to each elements so perform your comparsion
console.log(myArray[index]['os'])
});
}