
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 += "<table>"
for (var i = 0; i < persons.length; i++) {
    str += "<tr>"
    var key = Object.keys(persons[i]);
    for (var c = 0; c < key.length; c++) {
        if(c < 3)
            str += "<td>" + key[c] + ": " + persons[i][key[c]] + "</td>";
        if(c >= 3 && key[c] in persons[i])
            str += "<td>" + key[c] + ": " + persons[i][key[c]] + "</td>";
    }
    str += "</tr>"
}
str += "</table>";
document.write(str);