Object.isEqual

tyler clark tylerc644 at gmail.com
Mon May 1 19:40:14 UTC 2017


Hello All!

I am reaching out today to get some feedback on my proposal and hopefully
find a champion that will represent me and my idea.

Multiple times throughout my javascript projects I have found it necessary
to compare two objects. More recently, while working in React I ran into an
issue where I needed to compare responses from an API and had to use
LoDash's isEqual to do it.

As we all know Javascript takes into count memory reference when comparing
objects, not the individual keys and values. I am proposing we create a
method on the Object constructor that takes in objects and returns true or
false if the provided arguments have the exact same keys and values.

For example, this returns false:

const one = {test: 'test'}

const two = {test: 'test'}

const one === const two

The new method would look like this and will return true:

Object.isEqual(one, two)

I have the rough draft code to propose here:

https://jsfiddle.net/pdoutbnm/2/

Thank you,

Tylerc
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20170501/00a1fcc1/attachment.html>


More information about the es-discuss mailing list