我有一个对象,想要获取每个迭代器的键和值。
例如: -
var async=require('async')
var a1={'1':'fadfa','2':2,'3':3};
async.forEachSeries(a1, function(n1, callback) {
console.log(n1); // here i need key and value in each iterator.
callback();
});
答案 0 :(得分:1)
使用它:
var async=require('async')
var a1={'1':'fadfa','2':2,'3':3};
async.forEachSeries(Object.keys(a1), function(n1, callback) {
var key = n1;
var value = a1[key];
console.log(key + " " + value);
callback();
});