var a = { name: "Ivan", surname: "Ivanov", } var b = { name: "Petr", surname: "Petrov", } var c = { name: "Alex", surname: "Sidarov", } a.age = 20; b.fathername = "Nikolai"; c.sex = "male"; var persons = [a,b,c, { name: "pasha", surname: "efimenko", age: 22 } ] var str = ""; str += "
" + key[c] + ": " + persons[i][key[c]] + " | "; if(c >= 3 && key[c] in persons[i]) str += "" + key[c] + ": " + persons[i][key[c]] + " | "; } str += "