Hoisting - Supercharged

preview_player
Показать описание
When you declare functions in JavaScript, they are “hoisted”. Surma explains how in this video.

Рекомендации по теме
Комментарии
Автор

Surma needs a smoking jacket whilst in that wingback

waza
Автор

i remember wasting about 1 hour debuging why i could console.log a variable before i declared it, using *var* . it was painful to accept but now i use *let* and *const* all the time. the dark ages of *var* are gone

dandan
Автор

Thanks I never know that! So don't use const except at the very top before everything else

Nonenone-rjyp
Автор

This is not true. Let and const are hoisted, as you can see in the following example:

let x = 5;
{
console.log(x);
let x;
}

This throws "x is not defined."
If we remove the inner declaration, the code prints 5 as expected.

AssemblyWizard
Автор

oh ... seems like 'var' is really gone...

MehdiRaash
Автор

If functions are hoisted why classes are not hoisted?

siddharthasarma
Автор

hi, i've watch a lot of Google chrome dev video, and sometime ou talk about inline style like something cool/acceptable but teacher say me it's evil !!

FunkyFrogProject