Defining Objects

From rbachwiki
Revision as of 23:45, 1 November 2016 by Bacchas (talk | contribs)
Jump to navigation Jump to search
 var john = {
    name: 'John',
    lastName: 'Smith',
    yearOfBirth: 1990,
    job: 'Teacher',
    isMarried: false,
    family: ['jane', 'mark'],
    calculateAge: function(yob) {
        return 2016 - yob;
    }
};

console.log(john.calculateAge(1990));

Loop through items

for(var item in john ){
console.log(item + " - " + john [item]);

Back To Top- Home - Category