I am wondering how to get only some of the elements of an object using only for-in and if-else.
For example, if we have the following object:
var person,
property;
person = {
firstName: "John",
lastName: "Smith",
profession: "Lawyer",
age: 31,
eyeColor: "blue",
hairColor: "blonde"
}
How do I print out only the second and fourth property of this object with for-in and if-else?
Aucun commentaire:
Enregistrer un commentaire