const columns =["c","f","e","d","a","b","g"];
const experienceObject = {"Username":"participant1","Email":"P1@email.com","a":true,"b":true},{"Username":"participant2","Email":"P2@email.com","c":true,"d":true};
for (property in experienceObject) {
var Username = experienceObject[property].Username;
var Email = experienceObject[property].Email;
for (propertyCol in columns) {
function loopID(a){
var aL = columns.length;
var output = '';
for(var i = 0; i < aL; i++ ){
output += columns[i]+'('+experienceObject[property].columns[i]+')';
}
return output;
}
}
getFunction = loopID();
答案 0 :(得分:0)
基于类似以下内容的评论
var results;
for (property in experienceObject) {
if (columns.includes(property))
{
results[property] = experienceObject[property];
}
}
return results;
下面的旧答案
也许您打算这样做
const experienceObject =
{"Username":"participant1","Email":"P1@email.com","a":true,"b":true},
{"Username":"participant2","Email":"P2@email.com","c":true,"d":true};
成为这个
const experienceObject =
[{"Username":"participant1","Email":"P1@email.com","a":true,"b":true},
{"Username":"participant2","Email":"P2@email.com","c":true,"d":true}];
因此它是一个数组,而不是该行上的第二个对象。
这意味着您也想要吗?
for (property in experienceObject[0]) {