Skip to content

Instantly share code, notes, and snippets.

@tekaratzas
Last active July 24, 2017 13:24
Show Gist options
  • Save tekaratzas/ecb4f58f98bd46252f078bf7926175b3 to your computer and use it in GitHub Desktop.
Save tekaratzas/ecb4f58f98bd46252f078bf7926175b3 to your computer and use it in GitHub Desktop.
Semi-Colon Hell Javascript
/**
Here, the parser will add a semi colon after return causing the function to return undefined.
**/
function test(){
var name = "Hello";
return // it will add a ; here
{
name: name
}
}
/**
This one is even weirder.....
It does't add it in the case of a leading parenthesis
You end up with a type error since is assumes "console.log()" is a function and (someList || []) is its parameter
**/
function test2(){
var someList = undefined
console.log("Hi!") // does not add it here!
(someList || []).map((item) => item)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment