Skip to content

Instantly share code, notes, and snippets.

@eugenserbanescu
Created July 25, 2018 12:42
Show Gist options
  • Save eugenserbanescu/6a79ade1c03bda904abffcf1e16ddfec to your computer and use it in GitHub Desktop.
Save eugenserbanescu/6a79ade1c03bda904abffcf1e16ddfec to your computer and use it in GitHub Desktop.
Two scenarios where semicolons would prevent an error
try {
let obj = {a: 0}
let a = obj
[0,1,2].forEach(item => console.log(item))
} catch (e) {
console.log('First scenario', e) // throws TypeError: Cannot read property 'forEach' of undefined
}
try {
let obj2 = {a:0}
let c = obj2
(function(){
console.log('IIFE here')
})()
} catch (e) {
console.log('Second scenario', e) // throws TypeError: obj2 is not a function
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment