Asked 7 years ago
17 Jan 2017
Views 1465
lain

lain posted

How JavaScript work ?

How JavaScript work ?
Nilesh

Nilesh
answered Nov 30 '-1 00:00

How JavaScript work behind the scene ?

Firstly computer do not understand JavaScript . it understand machine code which is also called byte code .
machine code is not human understandable or readable , so we need some way to code so we can do it human friendly.

as below image JavaScript is top from the three under layer . which base result is byte code / machine code.



JavaScript is made on C++ , at execution JavaScript use C++ based lib and C++ convert to assembly language and finally convert to byte code . this process called compile .

Rasi

Rasi
answered Nov 30 '-1 00:00

JavaScript is single threaded script , single threaded means it run one thread at a time

var d=0;
d++;

in above code it will run one by one script . first var d=0; and than d++;

it use call stack to run function , call stack is stack function of the running . call stack have LIFO(Last in first out) order execution .


function first(){
console.log('first')
}
function second(){
return first();
}
second();

first come in stack is second() than first() and first() goes first out and than second() so i called it LIFO (Last in First out ) order.
Post Answer