Skip to content

Instantly share code, notes, and snippets.

@ApolloTang
Forked from tekaratzas/semi-colon.js
Created July 24, 2017 08:10
Show Gist options
  • Save ApolloTang/6b3593dab1c19d081edc27f7dd5639aa to your computer and use it in GitHub Desktop.
Save ApolloTang/6b3593dab1c19d081edc27f7dd5639aa 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 nothing.
**/
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