Javascript Questions:
JavaScript is a single-threaded (can handle single execution at a time) and
syncronous
Basic:
Temporal Dead Zone : Variables can’t be accessed until it is initialised.
useEffect Hook: used to handle side effects in functional components, (like api
calling)
useEffect(() => {}, []) vs useEffect(() => {}) => dependency array, in 1st one effect
runs only once when the component mounts, 2nd one runs all the time when
ever component rerenders.
1.Difference between “==” and “===”? (loose and strict equality check)
== -> compares only value, conversion one data type to another and checks
=== -> compares value as well as type
Objects are compared by references not by value (== or ===).
Coercion: type conversion
2. Key features for ES6:
Arrow functions, Template literals (Backticks), destructuring assignment
(extracts values from obj/arr), Promises, enhanced object literals
3.Event Loop: checks if callStack is empty, and then sends the web APIs, and
eventHandlers from the Task Queue.
MicroTask queue: for promises, then, catch, finally, await functions methods
Event loop gives priority to microtask queue.
Execution context : When JS engine scans the Js script file, which creates an
environment to run code (Memory (variable environment) – where all the
variables and functions get memory allocation and code block(Thread of
execution) – where code get executed synchronously in a specific order
Two phases in EC: Creation Phase(hoisting), Execution Phase(executes JS code
in EC)
4. Hoisting: the variable and function declaration are stored in memory for an
execution context before we execute our code.
5. Let, Const, Var difference:
Let, Const – Block scoped,
Var – Function Scoped
Promises: