Trying Java M Sure Go Comparing Properties Hints Start Woudl Appreciated Deep Comparison O Q12170665

I am trying to do this in java but I’m not sure how to go aboutcomparing the properties. Any hints on how to start woudl beappreciated.

Deep comparison

The == operator compares objects by identity. But sometimes, youwould prefer to compare the values of their actual properties.

Write a function, deepEqual, that takes two values and returnstrue only if they are the same value or are objects with the sameproperties whose values are also equal when compared with arecursive call to deepEqual.

To find out whether to compare two things by identity (use the=== operator for that) or by looking at their properties, you canuse the typeof operator. If it produces “object” for both values,you should do a deep comparison. But you have to take one sillyexception into account: by a historical accident, typeof null alsoproduces “object”.

// Your code here.var obj = {here: {is: “an”}, object: 2};console.log(deepEqual(obj, obj));// → trueconsole.log(deepEqual(obj, {here: 1, object: 2}));// → falseconsole.log(deepEqual(obj, {here: {is: “an”}, object: 2}));// → true

“We Offer Paper Writing Services on all Disciplines, Make an Order Now and we will be Glad to Help”

2 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published.