Have a look into the es6 code below:
let person = "John Malkovich"
(() => {
console.log("Original person was ", person);
person = "Drew Barrymore";
console.log("New person " + person);
})();
When I execute this program it throws me this error:
"TypeError: \"John Malkovich\" is not a function
Now I know that if I add a ;
at the end of line 1 i.e let person = "John Malkovich";
the program works. My only headache is not being able to understand why that weird error is occurring.