alok722.github.io/namaste-javascript-notes/dist/lectures.html
1 Users
0 Comments
88 Highlights
0 Notes
Tags
Top Highlights
Program in JS engine or browser that frees up unused memory.
JS is a synchronous, single-threaded language
Everything in JS happens inside the execution context
hold info about the env.
Javascript manages code execution context creation and deletion with the the help of Call Stack.
Memory component has all the variables and functions in key value pairs. It is also called Variable environment.
Code component is the place where code is executed one line at a time. It is also called the Thread of Execution.
Synchronous:- One command at a time. Single-threaded:- In a specific synchronous order.
When a JS program is ran, a global execution context is created.
execution context is created in two phases
Memory creation phase - JS will allocate memory to variables and functions. Code execution phase
var square2 = square(n), here functions are a bit different than any other language. A new execution context is created altogether
Call Stack maintains the order of execution of execution contexts.
Hoisting is a concept which enables us to extract values of variables and functions even before initialising/assigning value without getting error and this is happening due to the 1st phase (memory creation phase) of the Execution Context
if we remove var x = 7; then it gives error. Uncaught ReferenceError: x is not defined
before code execution, memory is created so in case of variable, it will be initialized as undefined while in case of function the whole function code is placed in the memory
console.log(x); // Uncaught Reference: x is not defined.
in summary, along with GEC, a global object (window) and a this variable are created
If we create any variable in the global scope, then the variables get attached to the global object.
fined. undefined is when memory is allocated for the variable, but no value is assigned yet
Glasp is a social web highlighter that people can highlight and organize quotes and thoughts from the web, and access other like-minded people’s learning.