Category: JavaScript interview questions
-
What is the difference between Object.entries, Object.keys and Object.values methods?
This is a popular JavaScript interview question to test knowledge about the Object methods. We’ll discuss all these three methods with an example. 1. Object.entries() The Object.entries() method returns an array of given object’s own enumberable [key, value] pairs. The order of the array returned by Object.entries() is same as that provided by a for…in…
-
How to clone an object in JavaScript?
Here we are considering only shallow copy of objects. We are not considering deep cloning of objects. Following are the common ways of cloning object in JavaScript: 1. Object.assign() method The Object.assign() method is used to copy the values of all enumerable own properties from one or more source objects to a target object. It…
-
What is the difference between == and === operator?
JavaScript has both strict and type–converting comparisons. The equality operator converts the operands if they are not of the same type, then applies strict comparison. If both operands are objects, then JavaScript compares internal references which are equal when operands refer to the same object in memory. The identity operator returns true if the operands…