-
Template Literals use back-ticks (``) rather than the quotes ("") to define a string. Template literals provide an easy way to interpolate variables and expressions into strings using ${}.
-
Destructuring in Javascript makes it possible to unpack properties from objects and values from arrays into distinct variables.
-
JavaScript provides both strict(===, !==) and non-strict(==, !=) equality comparison. Following are the special cases:
-
NaN is not equal to anything, including NaN.
-
Two objects are strictly equal if they refer to the same object.
-
Null and Undefined types are not equal with === but equal with ==.
- null===undefined --> false
- null==undefined --> true
Some of the example which covers the above cases:
0 == false // true 0 === false // false 1 == "1" // true 1 === "1" // false null == undefined // true null === undefined // false '0' == false // true '0' === false // false []==[] or []===[] //false, refer different objects in memory {}=={} or {}==={} //false, refer different objects in memory
-
-
A primitive data type is data that has a primitive value (which has no properties or methods). There are 7 types of primitive data types.
- string
- number
- boolean
- null
- undefined
- bigint
- symbol
In JavaScript, all numbers are stored in a 64-bit floating-point format (IEEE 754 standard). With this standard, large integer cannot be exactly represented and will be rounded. Because of this, JavaScript can only safely represent integers: Up to 9007199254740991 and Down to -9007199254740991. Integer values outside this range lose precision.
Objects are Non-primitive Data Types.
-
Hoisting is a JavaScript mechanism where variables, function declarations and classes are moved to the top of their scope before code execution. JavaScript only hoists declarations, not initialisation. In the same fashion, function declarations are hoisted too.
Whenever we execute JavaScript code, it creates a Global Execution Context The global execution context has two phases.
-
Creation Phase: If there are any variables declared in the code, the memory gets allocated for the variable. The variable gets initialized with a unique value called undefined. If there is a function in the code, it gets placed directly into the memory.
-
Execution Phase: The code execution starts in this phase. Here, the value assignment of the global variables takes place.
-
-
-
var declarations are globally scoped or function scoped while let and const are block scoped.
-
var variables can be updated and re-declared within its scope
-
let variables can be updated but not re-declared
-
const variables can neither be updated nor re-declared.
-
They are all hoisted to the top of their scope. But while var variables are initialized with undefined. let and const variables are not initialized.
-
While var and let can be declared without being initialized, const must be initialized during declaration.
-
-
The Temporal Dead Zone is a behavior in JavaScript that occurs when declaring a variable with the let and const keywords, but not with var.
In ECMAScript 6, accessing a
let
orconst
variable before its declaration (within its scope) causes a ReferenceError. The time span when that happens, between the creation of a variable’s binding and its declaration, is called the temporal dead zone. -
In normal functions, a this variable is created which references the objects that call them. In arrow function, this variable is not created. this is always global "this" regardless of strictness.
Furthermore, when invoking arrow functions using call(), bind(), or apply(), the this arg parameter is ignored.
-
Call: The call() method invokes a function with a given
this
value and arguments provided one by one.Apply: Invokes the function with a given
this
value and allows you to pass in arguments as an arrayBind: returns a new function, allowing you to pass any number of arguments
Call and Apply are pretty much interchangeable. Both execute the current function immediately. You need to decide whether it’s easier to send in an array or a comma separated list of arguments. You can remember by treating Call is for comma (separated list) and Apply is for Array.
Bind creates a new function that will have
this
set to the first parameter passed to bind(). -
In ES6, Javascript classes are primarily syntactic sugar over JavaScript’s existing prototype-based inheritance.
-
- Prototypes are the mechanism by which JavaScript objects inherit features from one another.
- Prototype chaining is used to build new types of objects based on existing ones.
- It is similar to inheritance in a class based language.
- The prototype on object instance is available through Object.getPrototypeOf(object) or proto property
-
Below are the list of statements used in an error handling:
- try: This statement is used to test a block of code for errors
- catch: This statement is used to handle the error
- throw: This statement is used to create custom errors.
- finally: This statement is used to execute code after try and catch regardless of the result.
-
A closure is the combination of a function bundled together (enclosed) with references to its surrounding state (the lexical environment).
In other words, a closure gives you access to an outer function's scope from an inner function. The closure has three scope chains:
- Own scope where variables defined between its curly brackets
- Outer function’s variables
- Global variables
-
Currying is the process of taking a function with multiple arguments and turning it into a sequence of functions each with only a single argument.
Currying is named after a mathematician Haskell Curry. By applying currying, an n-ary function turns into a unary function.
-
A callback function is a function that is passed as an argument to another function, to be “called back” at a later time.
A function that accepts other functions as arguments is called a higher-order function, which contains the logic for when the callback function gets executed.
-
Notifications
You must be signed in to change notification settings - Fork 0
rahul-sr/Frontend_Interview_Questions
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
About
No description, website, or topics provided.
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published