Skip to content

Instantly share code, notes, and snippets.

@LarrySul
Last active May 10, 2019 19:54
Show Gist options
  • Save LarrySul/654f62cb51773cdacb6f7e142df63f6b to your computer and use it in GitHub Desktop.
Save LarrySul/654f62cb51773cdacb6f7e142df63f6b to your computer and use it in GitHub Desktop.
javascript object methods
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