skip to Main Content

lexical scope in Javascript issue

in the following code snippet, I defined "bob" first, but the output is "alice:1 hi alice", I don't know why? let user = ""; function greet() { console.count(user); return `hi ${user}`; } user = "bob"; user = "alice"; console.log(greet());//alice:1 hi…

VIEW QUESTION
Back To Top
Search