Last active
August 29, 2015 14:22
-
-
Save mbuttler/0a79371ccc1b90280f82 to your computer and use it in GitHub Desktop.
Matt's Javascript Question of the Day
This file contains 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
// behold, an object. | |
var neutralFolk = {}; | |
// when I go to check this, I get an "unexpected token ." syntax error. Why? | |
var enemies = { | |
enemies.khan = {}; | |
enemies.salazar = {}; | |
}; | |
// my understanding is that I should be able to define my object properties | |
// within the curly braces that set the ememies object up... know what I mean? | |
// just to prove I'm not a complete fool, it DOES pass when I use a new object Constructor. | |
var friends = new Object(); | |
{ | |
friends.bill = {}; | |
friends.steve = {}; | |
}; | |
// so what am I doing wrong in the enemies object? I want to know how to do this without needing a new object | |
// constructor when I create a new object. Shouldn't I just be able to shorthand define it? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Should be like this: