🚨 JavaScript Interview Question What will be the output? const obj1 = { name: "Suman" }; const obj2 = { name: "Suman" }; console.log(obj1 == obj2); console.log(obj1 === obj2); At first glance, many developers expect the result to be true because both objects have the same values. But JavaScript compares objects by reference, not by value. Even if two objects contain identical properties, they are stored in different memory locations. So what do you think the output will be? #JavaScript #FrontendInterview #ReactJS #FrontendDeveloper #FrontendArchitecture #ProductBasedCompany
Ans1. True because == is loose equality check, it compare value only.2. False because === is strict equality check, it compare datatype or reference also.
false
Ans : console.log(obj1 == obj2); = false console.log(obj1 === obj2); = false Both have the same data, but their memory locations are different.
At first glance many developer expect the result to be true which is not correct then surely the answer will be false
false false
false
false false
Primitive (string, number, boolean) → value compare Objects, arrays, functions → reference compar
false in both cases
Currently exploring Frontend (React.js) opportunities | 2.5 YOE | Serving notice period Open to referrals and opportunities. Happy to share my resume 🙌