What do you think this piece of code will print? Most of you might know the answer but the behavior is really interesting to me and got me thinking and learning about a very important concept in JS.
function saySomething() {
var greeting = "Hello";
{
greeting = "Howdy";
let greeting = "Hi";
console.log(greeting);
}
}
saySomething(); //what would this print?
Top comments (3)
error. It returns an error.
developer.mozilla.org/en-US/docs/W...
Console error I think invalid token.
Interesting, could you help understand why it is throwing an error?