Skip to content

Instantly share code, notes, and snippets.

@akinjide

akinjide/asi.js

Created May 11, 2017
Embed
What would you like to do?
JavaScript nasty ASI (Automatic Semicolon Insertion)
var hello = "Hello World"
console.log(hello)
// Error.
(function() {
console.log("¯\_(ツ)_/¯")
}())
// Solution 1
;(function() {
console.log("¯\_(ツ)_/¯")
}())
// Solution 2
function shrug() {
console.log("¯\_(ツ)_/¯")
}
shrug()
// Error.
[1, 2, 3].forEach(function(x) {
console.log(x)
})
// Solution 1
var numbers = [1, 2, 3]
numbers.forEach(function(x) {
console.log(x)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.