Created
April 22, 2017 16:33
-
-
Save redblobgames/acda143f7172cf34871dfcbe5d369cf5 to your computer and use it in GitHub Desktop.
Befuddled
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
// I wrote wrong1 vs right1 to demonstrate automatic semicolon insertion. So far so good. | |
function wrong1(x) { | |
return | |
{ | |
upper: x + 1 | |
}; | |
} | |
function right1(x) { | |
return { | |
upper: x + 1 | |
}; | |
} | |
// But I also had tried the same example with *two* fields in the object. But this is a parse error. Why? | |
function wrong2(x) { | |
return | |
{ | |
upper: x + 1, | |
lower: x - 1 | |
}; | |
} | |
function right2(x) { | |
return { | |
upper: x + 1, | |
lower: x - 1 | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment