UNPKG

@rahmatsaeedi/lotide

Version:

A light-weight, simplified, & minified version of Lodash library

26 lines (22 loc) 660 B
// Take in two objects, checks whether that the two are identical, and returns a boolean. // Supports nested objects with premitive values, and arrays. // jshint esversion : 6 const eqObjects = function(object1, object2) { if (Object.keys(object1).length !== Object.keys(object2).length) { return false; } else { for (let k in object1) { if (object1[k] instanceof Object) { if (!eqObjects(object1[k], object2[k])) { return false; } } else { if (object1[k] !== object2[k]) { return false; } } } return true; } }; module.exports = eqObjects;