Skip to content

Instantly share code, notes, and snippets.

@redblobgames
Created April 22, 2017 16:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save redblobgames/acda143f7172cf34871dfcbe5d369cf5 to your computer and use it in GitHub Desktop.
Save redblobgames/acda143f7172cf34871dfcbe5d369cf5 to your computer and use it in GitHub Desktop.
Befuddled
// 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