Created
July 25, 2018 12:42
-
-
Save eugenserbanescu/6a79ade1c03bda904abffcf1e16ddfec to your computer and use it in GitHub Desktop.
Two scenarios where semicolons would prevent an error
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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