process.on('exit', function () {
console.log("Exiting normally")
})
process.on('uncaughtException', function (err) {
console.log("Caught - " + err)
})
[1,2,3,4,5].forEach(function(element) {
console.log("Loop " + element)
})
This breaks with:
Caught - TypeError: Cannot read property 'forEach' of undefined
Exiting normally
Whereas when I add a semi-colon, it works:
process.on('exit', function () {
console.log("Exiting normally")
})
process.on('uncaughtException', function (err) {
console.log("Caught - " + err)
}); // Added semi colon here
[1,2,3,4,5].forEach(function(element) {
console.log("Loop " + element)
})
Does this mean that I should be using semi-colons after every statement just to be safe?