Level-2 : Intermediate
-
What is Closure? What are the use cases of Closures?
- A closure is a function that retains access to its lexical scope even when the function is executed outside that scope. Use cases include data encapsulation, creating private variables, and function factories.
-
Explain the concept of hoisting in JavaScript.
- Hoisting is JavaScript's default behavior of moving declarations (not initializations) to the top of their containing scope during compilation.
vardeclarations are hoisted to the top of their function scope, whileletandconstdeclarations are hoisted to the top of their block scope but are not initialized.
- Hoisting is JavaScript's default behavior of moving declarations (not initializations) to the top of their containing scope during compilation.
-
What is a Temporal Dead Zone?
- The Temporal Dead Zone (TDZ) is the time period between entering a scope and the actual declaration of a variable where accessing the variable will result in a
ReferenceError.
- The Temporal Dead Zone (TDZ) is the time period between entering a scope and the actual declaration of a variable where accessing the variable will result in a
-
What is a prototype chain? and Object.create() method?
- The prototype chain is a series of linked prototypes. Every object has a prototype, and a prototype can have its own prototype, forming a chain.
Object.create(proto)creates a new object with the specified prototype.
- The prototype chain is a series of linked prototypes. Every object has a prototype, and a prototype can have its own prototype, forming a chain.
-
What is the difference between Call, Apply, and Bind methods?
call: Invokes a function with a specifiedthisvalue and arguments provided individually.apply: Invokes a function with a specifiedthisvalue and arguments provided as an array.bind: Returns a new function, permanently bound to the providedthisvalue and initial arguments.
-
What are lambda or arrow functions?
- Arrow functions are a concise syntax for writing functions using the
=>arrow notation. They do not have their ownthisvalue and cannot be used as constructors.
- Arrow functions are a concise syntax for writing functions using the
-
What is the currying function?
- Currying is the process of transforming a function that takes multiple arguments into a sequence of functions that each take a single argument.
-
What are the features of ES6?
- Some key features of ES6 (ECMAScript 2015) include:
letandconstdeclarations- Arrow functions
- Template literals
- Destructuring assignment
- Default parameters
- Rest and spread operators
- Classes
- Promises
- Modules (import/export)
- Enhanced object literals