Last active
May 10, 2019 19:54
-
-
Save LarrySul/654f62cb51773cdacb6f7e142df63f6b to your computer and use it in GitHub Desktop.
javascript object methods
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var person = { | |
firstName: "John", | |
lastName : "Doe", | |
id : 5566, | |
fullName : function() { | |
return this.firstName + " " + this.lastName; | |
}, | |
exam : function () { | |
return 'I have exam on Monday'; | |
} | |
}; | |
// to be able to access the data in person object we could do it so | |
console.log(person.firstName); // returns John | |
console.log(person.lastName); // returns Doe | |
console.log(person.id); // returns 5566 | |
console.log(person.fullName()); //returns John Doe | |
console.log(person.exam()); // returns I have exam on Monday | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment