I'm learning Javascript track in codecademy.com. And I'm confused about creating object by using "Object Literal Notation".
Here syntax1, in the hint section the syntax is:
var friends = {
bill: {},
steve: {}
};
We need those curly braces to contain keys' values within the object's curly brace.
BUT, in syntax2, the syntax is:
var myObject = {
key: value,
key: value,
key: value
};
See, no need for curly braces container within the object's curly brace. As I did the exercise we only required to: direct input for numbers and functions, or within quotation for strings, or within square brackets for arrays.
Can someone kindly share their knowledge and time to tell me why we have the difference or which one is the correct syntax?