How would you compare 2 objects in JavaScript? | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
+ 1

How would you compare 2 objects in JavaScript?

17th Jul 2017, 3:23 AM
kashish
5 Respostas
+ 5
https://code.sololearn.com/WeCZ41sKPLj5/?ref=app This code can compare your two manual object
17th Jul 2017, 10:44 AM
Yanothai Chaitawat
Yanothai Chaitawat - avatar
+ 5
@James :) :) :) :( :( :( :( :( It's not working with function anonymous :(
17th Jul 2017, 11:19 AM
Yanothai Chaitawat
Yanothai Chaitawat - avatar
0
What do you mean by "compare" exactly?
17th Jul 2017, 7:57 AM
James
James - avatar
0
@Very Hard The JSON.stringify() method is perfect!
17th Jul 2017, 10:56 AM
James
James - avatar
- 1
Well, you can compare them using the method typeOf, which returns the type of the objects and simply use if equal (==), distinct (!=), identical, (===) or not identical (!==). An object is identical to other if its type AND value of its attributes are exactly equal.
17th Jul 2017, 3:33 AM
voidneo