@object-prototype/equals

1.0.0 • Public • Published

How to use

Running index.js will add equals() to the prototype of Object. So ...

// Create two objects that are the same
const obj1 = {foo: "bar", baz:"qux", };
const obj2 = {foo: "bar", baz:"qux", };
// Add to Object.prototype
index.js
// Run some tests
console.assert( obj1.equals(obj2) );  // true
console.assert( obj2.equals(obj1) );  // true

// Note that two objects are never truly equal according to JavaScript unless they point to the same object in memory:
console.assert( (obj1 == obj2) === false);  
console.assert( (obj1 === obj2) === false);
// This is why we might want to have this prototype method. 

Package Sidebar

Install

npm i @object-prototype/equals

Weekly Downloads

1

Version

1.0.0

License

MIT

Unpacked Size

2.98 kB

Total Files

4

Last publish

Collaborators

  • object-prototype