var book = {
title: 'Nothing new!',
author: {name: 'Annyce', email:'annyce@gmail.com'}
};
You could then reference the author's name via:
book.author.name
and if you wanted to update the name of the author, you would use
book.author.name = 'Sarah';
This feature of Javascript becomes very useful when you attempt to create an object with default settings and so forth.
No comments:
Post a Comment