const obj1 = { id: 1 };
const obj2 = { id: 1 };
const obj3 = obj1;
console.log(obj1 === obj2);
console.log(obj1 === obj3);
What is the output of the above code
Anonymous Quiz
27%
false true
11%
true false
44%
true true
13%
false false
4%
error
Forwarded from αα₯αα½
Please open Telegram to view this post
VIEW IN TELEGRAM
This media is not supported in your browser
VIEW IN TELEGRAM
Been off latelyβ¦ had to train my finger to hit Tab professionally ποΈββοΈβ¨οΈ
#coding_meme@forcoder #codingmeme
#coding_meme@forcoder #codingmeme
for-coder
What is the output of the above code
Please open Telegram to view this post
VIEW IN TELEGRAM
Open your console and type:
typeof null
You'll get:
'object'
That's wrongβnull is not an object!
π How did this happen?
When JavaScript was first implemented, values were stored in a tagged format, where the lower bits determined the type:
-
Objects
had a type tag of 0. -
null
was stored as 0
in memory. Since
null
had 0
in its type tag, typeof
mistakenly classified it as an "object". π§ Why isn't it fixed?
One word: Backward compatibility.
Fixing it would break too many apps, so it's here to stay!
π¬ Share this with JavaScript haters
new
#JavaScript #Bug #Programming
This media is not supported in your browser
VIEW IN TELEGRAM
Difference between programmers and @astonhall