Local Storage

Local Storage and Session Storage Differences?

The read-only sessionStorage property accesses a session Storage object for the current origin. sessionStorage is similar to localStorage; the difference is that while data in localStorage doesn't expire, data in sessionStorage is cleared when the page session ends.

Whenever a document is loaded in a particular tab in the browser, a unique page session gets created and assigned to that particular tab. That page session is valid only for that particular tab.
A page session lasts as long as the tab or the browser is open, and survives over page reloads and restores.Opening a page in a new tab or window creates a new session with the value of the top-level browsing context, which differs from how session cookies work.

Opening multiple tabs/windows with the same URL creates sessionStorage for each tab/window.
Duplicating a tab copies the tab's sessionStorage into the new tab.Closing a tab/window ends the session and clears objects in sessionStorage.Data stored in sessionStorage is specific to the protocol of the page.

Global Scope and block scope Differences?

Global Scope :
The variables defined outside of any function or curly brackets are known as global variables and have global scope. Global scope means that the variables can be accessed from any part of that program, any function or conditional state can access that variable.

Local Scope :
If you were to define some variables inside curly brackets {} or inside a specific function then those variables are called local variables The local variables have a very confined scope which is called the local scope But, with the release of ES6, the local scope was further broken down into two different scopes: Function scope
Block scope.
Function Scope
The function scope is the accessibility of the variables defined inside a function, these variables cannot be accessed from any other function or even outside the function in the main file. Block Scope
Block scope is also a sub-type of local scope. The block scope can be defined as the scope of the variables inside the curly brackets {}. Now, these curly brackets can be of loops, or conditional statements, or something else. You are only allowed to refer to these variables from within the curly brackets {}.
Imagine a nested situation:
A block of code enclosed with curly brackets{} containing some block variables.

Global Scope
Shoes

Javascript event loop

Event Loop :
The event loop is the secret behind JavaScript's asynchronous programming. JS executes all operations on a single thread, but using a few smart data structures, it gives us the illusion of multi-threading.

Easy Definition :
The Event Loop has one simple job — to monitor the Call Stack and the Callback Queue or Message Queue.
If the Call Stack is empty, it will take the first event from the Callback queue and will push it to the Call Stack, which effectively runs it.
Such an iteration is called a tick in the Event Loop. Each event is just a function callback.

Easiest explanation :
When any Asynchronous event occur such as setTimeOut or promises... Then these task takes some time to complete I/O if they have any. If they completed their I/O or don't have any, then they simply put into message queue or callback queue. Then event loop will firstly execute the call stack tasks and then look for callback or message queue and then execute it..

Shoes

How many ways can we get the undefined errors in JavaScript?

undefined is a property of the global object. That is, it is a variable in global scope. The initial value of undefined is the primitive value undefined. In all non-legacy browsers, undefined is a non-configurable, non-writable property. (Even when this is not the case, avoid overriding it.) A variable that has not been assigned a value is of type undefined. A method or statement also returns undefined if the variable that is being evaluated does not have an assigned value. A function returns undefined if a value was not returned.

What is undefined
JavaScript has 6 primitive types:
Boolean: true or false
Number: 1, 6.7, 0xFF
String: "Gorilla and banana"
Symbol: Symbol("name") (starting ES2015)
Null: null
Undefined: undefined.
And a separated object type: {name: "Dmitri"}, ["apple", "orange"].
From 6 primitive types undefined is a special value with its own type Undefined. According to ECMAScript specification:

Undefined value primitive value is used when a variable has not been assigned a value.