The correct answer is Reference Error. The declaration of let does not hoist, however if we try to use the same name variable declared later in the block scope will look into the current scope only and not on parent scope.
-
-
Prikaži ovu nitHvala. Twitter će to iskoristiti za poboljšanje vaše vremenske crte. PoništiPoništi
-
-
-
What is the question even asking? What’s it return? What happens? What’s going on with this?
-
Ohh, sorry if this is unclear. You are supposed to guess the output of console log statement.
Kraj razgovora
Novi razgovor -
-
-
Undefined. foo() does not return a value.
-
the correct answer, wrong explanation. "i" has not been defined yet in the lexical scope of foo(), that's why undefined. Please correct if I'm wrong.
- Još 1 odgovor
Novi razgovor -
-
-
The right answer: use tools like eslint to not write horrible unreadable code like that.
Hvala. Twitter će to iskoristiti za poboljšanje vaše vremenske crte. PoništiPoništi
-
-
-
var is a global and function scope. But let is a block scope. The important thing let can' t hoisted. For that reason ReferenceError, cause function can not access 'i' before initialization.
-
damn me, true... wat a lame mistake, haha. if let was var, it would be hoisted and log 20.
- Još 1 odgovor
Novi razgovor -
-
-
The above example will be interpreted as: function foo(){ console.log(i); let i = 20; } var i; i=10; foo(); So it will give a Reference Error.
Hvala. Twitter će to iskoristiti za poboljšanje vaše vremenske crte. PoništiPoništi
-
-
-
ReferenceError
Hvala. Twitter će to iskoristiti za poboljšanje vaše vremenske crte. PoništiPoništi
-
Čini se da učitavanje traje već neko vrijeme.
Twitter je možda preopterećen ili ima kratkotrajnih poteškoća u radu. Pokušajte ponovno ili potražite dodatne informacije u odjeljku Status Twittera.

var i = 10
function foo(){
console.log(i) //