MERN stands for MongoDB, Express, React, Node, after the four key technologies that make up the stack. MERN Stack Interview Part 10 Javascript Questions.
Q91. What are the possible ways to create objects in JavaScript?
1. Object constructor
2. Object’s create method
3. Object literal syntax
4. ES6 Class syntax
Q92. What is a prototype chain?
Prototype chaining is used to build new types of objects base 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 whereas prototype on constructors function is available through Object.prototype.
Employee proto
Person proto
Object prototype
Q93. What is the difference between Call, Apply and Bind?
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 array
Bind: returns a new function, allowing you to pass any number of arguments.
Q94. What is JSON and its common operations?
JSON (JavaScript Object Notation (JSON)) is a text-based data format following JavaScript object syntax which was popularized by Douglas Crockford. It is useful when you want to transmit data across a network and it is basically just a text file with an extension of json, and a MIME type of application/json.
Q95. What is a first class function?
In Javascript, functions are first class objects. First-class functions means when functions in that language are treated like any other variable.
For example, in such a language, a function can be passed as an argument to other functions, can be returned by another function and can be assigned as a value to a variable.
For example, in the below example, handler functions assigned to a listener
const handler = () => console.log(‘This is a click handler function’);
document.addEventListener(“click”, handler);
Q96. What is a first order function?
First-order function is a function that doesn’t accept another function as an argument and doesn’t return a function as its return value.
Q97. What is a unary function?
Unary function is a function that accepts exactly one argument. It stands for a single argument accepted by a function.
Q98. What is the currying function?
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, a n-ary function turns it into a unary function.
Q99. What is a pure function?
A Pure function is a function where the return value is only determined by its arguments without any side effects. i.e, If you call a function with the same arguments ‘n’ number of times and ‘n’ number of places in the application then it will always return the same value.
Q100. What is the purpose of the array slice method?
The slice() method returns the selected elements in an array as a new array object. It selects the elements starting at the given start argument, and ends at the given optional end argument without including the last element. If you omit the second argument then it selects till the end.
let firstarray = [1, 2, 3, 4, 5]:
let newarray1 = firstarray.slice(0,3); // returns [1,2,3] let newarray2 = firstarray.slice(2); // returns [3, 4, 5]
Slice: The parameter ‘s’ indicates the starting index and ‘e’ indicates the ending index.
Splice: The parameter ‘i’ denotes the starting index, ‘n’ denotes the number of items to be removed from the specified starting index.
MERN Stack Interview Part 10. MERN Stack Interview MongoDB Express React Node Javascript.
Read Also: MERN Stack Interview Questions & Answer Series Part 9