Scopes and Closures In-depth 11 - Understanding the compilation phase

preview_player
Показать описание

This video explains in detail what the JavaScript engine does in the compilation phase.
Рекомендации по теме
Комментарии
Автор

In the first example, compilation happens in global scope where 2 variables are created: a with value: undefined and myFn that points to a newly created function object. Then immediately execution happens in global scope where variable a is assigned value: 10 and the myFn is invoked. Whenever a function is invoked, compilation and execution happens inside that function scope. In this case, when myFn is invoked, compilation happens in myFn scope where 2 variables are created: b and c both undefined. Then execution happens in myFn scope where values will be assigned to variables b & c and the console.log statement will be executed. I hope it'll be helpful to explain about execution contexts also here.

philipmat
Автор

These videos are golden! Amazing explanation. Can you do videos on 'Data Structures and Algorithms' please :)

jollydesigner
Автор

Hi, These sessions are too good. can u please share which tools you use to write and draw the content ?

devadventure-with-world
Автор

what diff between
var a=10;
b=20;
what will make sense on compile time for variable 'a' and variable 'b'.

saifaligour
Автор

What happens when we write

var a = function(){
var c;
}

Will the compilation step just register variable 'a' in global scope and skip function declaration and variable 'c' declaration since compilation step is supposed to skip the R.H.S. part and evaluating expressions comes under interpretor part.

pragun
Автор

What does it do when we create a variable name myName and function myName ?
Does it create two variables named myName of two different types?

kotesn
Автор

var a = 10;
var b = 20;
console.log(a+b);
var a = 20;
Hi koushik i have small doubt, as you are telling in compilation all variable are register na, in that case in my code it should print 40, but here it printing 30 only, can you please clear it

srikanthjanapati
Автор

var name = "Some name"

function foo() {
console.log(name);
}

foo("One name");

foo();


Output: Some name

Output is printed only once. Shouldn't the function "foo" be called twice and the Some name be printed twice?

shubhashish_das
Автор

These are very helpful videos ... but you're talking REALLY fast in this one haha ... maybe try decaf instead : P

gkniffen