OOP - accessing and searching
Assignment of variable to child object
var ageProperty = 'age';
var nameProperty = 'name';
console.log(person[ageProperty]);
Can be manipulated in RunTime
var userInput = prompt("What data do you want to bring? ");
console.log(person[userInput]);
input of a name of a property of the object
age
will return the data in the property
46
Loop over Object properties
var string1 = '';
var object1 = {a:1,b:2,c:3};
for (var property in object1){
string1 += object1[property] + " ";
}
console.log(string1);
will return sum of the values of each member of the object
6
back to main page