Skip to content

Instantly share code, notes, and snippets.

@scriptonian
Created January 11, 2018 16:18
Show Gist options
  • Save scriptonian/ecd4a4f4c2f062a4ad889602971b6440 to your computer and use it in GitHub Desktop.
Save scriptonian/ecd4a4f4c2f062a4ad889602971b6440 to your computer and use it in GitHub Desktop.
var book = {
tarzan : { publisher: "Pub A", author: "Author A", pageCount: 300},
cinderella : { publisher: "Pub B", author: "Author B", pageCount: 400},
"hidden universe" : { publisher: "Pub C", author: "Konstantin", pageCount: 1000},
addBook : function(name, publisher, author, pageCount) {
this[name] = {publisher: publisher, author:author, pageCount};
}
};
book.addBook('JS Objects', "Publisher Z", "Konstantin", 300);
console.log(book);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment