var a=[12,26,"pawan",77]; var b=[12,26,"pawan",77]; | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

var a=[12,26,"pawan",77]; var b=[12,26,"pawan",77];

Why a==b is not equal ?

20th May 2021, 2:07 PM
๐—ฃ๐—ฎ๐˜„๐—ฎ๐—ป ๐—ž๐˜‚๐—บ๐—ฎ๐—ฟ ๐Ÿ…Ÿ๏ธŽ๐Ÿ…š๏ธŽ
๐—ฃ๐—ฎ๐˜„๐—ฎ๐—ป ๐—ž๐˜‚๐—บ๐—ฎ๐—ฟ ๐Ÿ…Ÿ๏ธŽ๐Ÿ…š๏ธŽ - avatar
3 Answers
0
because a and b hold two different objects, even if their items values are equals ^^
20th May 2021, 2:15 PM
visph
visph - avatar
+ 4
Variables, a and b each contain only a reference to a location in memory. Not the value of theย object. The locations are separate, so the references are different, and theย comparisonย return false.
20th May 2021, 2:34 PM
Apongpoh Gilbert
Apongpoh Gilbert - avatar
- 1
Oo I think
20th May 2021, 2:28 PM
๐—ฃ๐—ฎ๐˜„๐—ฎ๐—ป ๐—ž๐˜‚๐—บ๐—ฎ๐—ฟ ๐Ÿ…Ÿ๏ธŽ๐Ÿ…š๏ธŽ
๐—ฃ๐—ฎ๐˜„๐—ฎ๐—ป ๐—ž๐˜‚๐—บ๐—ฎ๐—ฟ ๐Ÿ…Ÿ๏ธŽ๐Ÿ…š๏ธŽ - avatar