Answer Of Some Of Questions
Local Storage Vs. Session Storage
Session Storage: The sessionStorage object stores data only
for a session. It means that the data stored in the sessionStorage
will be deleted when the browser is closed.
Local Storage: Unlike sessionStorage localStorage continues
to store data after the browser is closed. It means that data stored
in localStorage does not expire.
Global Scope Vs. Block Scope
Scope: Visibility or Accessibility of a variable.
Global Scope: If a variable is declared outside all functions
or curly braces ({ ... }), it is said to be defined in the global scope.
Once you’ve declared a global variable, you can use that variable
anywhere in your code, even in functions.
Block Scope: When you declare a variable with const or let
within a curly brace ({ ... }), you can access this variable only within
that curly brace.
What is Event Loop?
Event Loop: It's a fundamental piece of the JavaScript engine
that always monitor call stack, task queue and microtask queue. If
the call stack is empty it puts callback function in call stact from
task queues.
When do we get undefined
in JavaScript?
1. When try to accessing an uninitialized variable.
2. When a function does not return anything it return
undefined.
3. When you try to access a property of an object that does not
exist.
4. When try to accessing out-of-bounds array elements.