Javascript interview fun snippets

Vineet Mishra
Mar 27, 2022

--

Q1. Guess the output:

const obj = {
prop: 42
};
Object.freeze(obj);
obj.prop = 33;

console.log(obj.prop);

Take your time, don’t jump into a solution think hard

Output:
42

Q2.Guess the output

let obj1 ={name:”vineet”}
let obj2 ={name:”vineet”}
console.log(obj1===obj2);
console.log(JSON.stringify(obj1)===JSON.stringify(obj2));
console.log(obj1==obj2);
console.log(JSON.stringify(obj1)==JSON.stringify(obj2));

Take your time, don’t jump into a solution think hard

Output:
false
true
false
true

--

--

Vineet Mishra
Vineet Mishra

Written by Vineet Mishra

SDE 2 at Accelya , I write about Mobile/Web Development and Deployment, and Interview Q & A

No responses yet