Last active
January 28, 2019 02:39
-
-
Save Maccauhuru/57b2ab0b7de0475e84192bb31b1d8da5 to your computer and use it in GitHub Desktop.
Example Object Definition
This file contains hidden or 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
//lets define an object called book | |
const book = {}; | |
//lets add two properties to our book object | |
book.name = "Eloquent JavaScript: A Modern Introduction to Programming"; | |
book.author = "Marijn Haverbeke" | |
//lets define a method to get the book details | |
book.getBookDetails = function (){ | |
return "The book " + this.name + " was written by " + this.author; | |
} | |
console.log(book.name);//"Eloquent JavaScript: A Modern Introduction to Programming" | |
console.log(book.author);//"Marijn Haverbeke" | |
console.log(book.getBookDetails()); | |
//"The book Eloquent JavaScript: A Modern Introduction to Programming was written by Marijn Haverbeke" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment