Write down differences between local storage and session storage.
The localStorage :
The localStorage stores the data with no expiration date. The data will not be deleted
when
the browser is
closed, and will be available the next day, week, or year.
Data is shared between all tabs and windows from the same origin.
The sessionStorage :
The sessionStorage is equal to the localStorage, except that it stores the data for
only one session.
The
data is deleted when the user closes the specific browser tab.
It is shared between iframes in the same tab.
Write down differences between global scope and block scope.
The global scope :
The global scope is the scope that contains, and is visible in, all other scopes. A
global variable has global scope.
A global variable is accessible from anywhere in the
code.
The Local scope :
Local scope contains things defined inside code blocks.
A local variable has local
scope.
A local variable is only
accessible where it’s declared.
How does the event-loop in JavaScript work?
The Event Loop :
The event loop is a constantly running process that monitors both the callback queue and the
call stack.
The Event Loop has one simple job — to
monitor the Call Stack and the Callback Queue. If the Call Stack is empty, the
Event Loop will take the first event from the queue and will push it to the Call Stack,
which effectively runs it.
Each event is just a function callback.
How many types of undefined we get?
A variable that is declared/created but
not assigned with a value anywhere in the program has a default value of
“undefined”.
Types of undefined we can get —
1: without any value has a value of undefined.
2: type of an empty string.
3: empty an existing variable that has some existing value by setting its value as
undefined.