Commit 914b11a1 authored by MohammadAli Keshavarz's avatar MohammadAli Keshavarz

Objects and methods

parent af8d2f4f
......@@ -317,7 +317,7 @@ console.log(isDesigner);
/*****************************
* Objects and properties
*/
/*
// Object literal
var john = {
firstName: 'John',
......@@ -340,5 +340,27 @@ jane.firstName = 'Jane';
jane.birthYear = 1969;
jane['lastName'] = 'Smith';
console.log(jane);
*/
/*****************************
* Objects and methods
*/
var john = {
firstName: 'John',
lastName: 'Smith',
birthYear: 1992,
family: ['Jane', 'Mark', 'Bob', 'Emily'],
job: 'teacher',
isMarried: false,
calcAge: function() {
this.age = 2018 - this.birthYear;
}
};
john.calcAge();
console.log(john);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment