function isEqual(a, b) {if (a === b) {return true;}
if (generalType(a) != generalType(b)) {return false;}
if (a == b) {return true;}
if (typeof a != 'object') {return false;}
// null != {}if (a instanceof Object != b instanceof Object) {return false;}
if (a instanceof Date || b instanceof Date) {if (a instanceof Date != b instanceof Date ||a.getTime() != b.getTime()) {return false;}}
var allKeys = [].concat(keys(a), keys(b));uniqueArray(allKeys);
for (var i = 0; i < allKeys.length; i++) {var prop = allKeys[i];if (!isEqual(a[prop], b[prop])) {return false;}}return true;}
function objectEquals(x, y) {'use strict';
if (x === null || x === undefined || y === null || y === undefined) { return x === y; }// after this just checking type of one would be enoughif (x.constructor !== y.constructor) { return false; }// if they are functions, they should exactly refer to same one (because of closures)if (x instanceof Function) { return x === y; }// if they are regexps, they should exactly refer to same one (it is hard to better equality check on current ES)if (x instanceof RegExp) { return x === y; }if (x === y || x.valueOf() === y.valueOf()) { return true; }if (Array.isArray(x) && x.length !== y.length) { return false; }
// if they are dates, they must had equal valueOfif (x instanceof Date) { return false; }
// if they are strictly equal, they both need to be object at leastif (!(x instanceof Object)) { return false; }if (!(y instanceof Object)) { return false; }
// recursive object equality checkvar p = Object.keys(x);return Object.keys(y).every(function (i) { return p.indexOf(i) !== -1; }) &&p.every(function (i) { return objectEquals(x[i], y[i]); });}
////////////////////////////////////////////////////////////////// The borrowed tests, run them by clicking "Run code snippet"///////////////////////////////////////////////////////////////var printResult = function (x) {if (x) { document.write('<div style="color: green;">Passed</div>'); }else { document.write('<div style="color: red;">Failed</div>'); }};var assert = { isTrue: function (x) { printResult(x); }, isFalse: function (x) { printResult(!x); } }assert.isTrue(objectEquals(null,null));assert.isFalse(objectEquals(null,undefined));assert.isFalse(objectEquals(/abc/, /abc/));assert.isFalse(objectEquals(/abc/, /123/));var r = /abc/;assert.isTrue(objectEquals(r, r));
assert.isTrue(objectEquals("hi","hi"));assert.isTrue(objectEquals(5,5));assert.isFalse(objectEquals(5,10));
assert.isTrue(objectEquals([],[]));assert.isTrue(objectEquals([1,2],[1,2]));assert.isFalse(objectEquals([1,2],[2,1]));assert.isFalse(objectEquals([1,2],[1,2,3]));
assert.isTrue(objectEquals({},{}));assert.isTrue(objectEquals({a:1,b:2},{a:1,b:2}));assert.isTrue(objectEquals({a:1,b:2},{b:2,a:1}));assert.isFalse(objectEquals({a:1,b:2},{a:1,b:3}));
assert.isTrue(objectEquals({1:{name:"mhc",age:28}, 2:{name:"arb",age:26}},{1:{name:"mhc",age:28}, 2:{name:"arb",age:26}}));assert.isFalse(objectEquals({1:{name:"mhc",age:28}, 2:{name:"arb",age:26}},{1:{name:"mhc",age:28}, 2:{name:"arb",age:27}}));
Object.prototype.equals = function (obj) { return objectEquals(this, obj); };var assertFalse = assert.isFalse,assertTrue = assert.isTrue;
assertFalse({}.equals(null));assertFalse({}.equals(undefined));
assertTrue("hi".equals("hi"));assertTrue(new Number(5).equals(5));assertFalse(new Number(5).equals(10));assertFalse(new Number(1).equals("1"));
assertTrue([].equals([]));assertTrue([1,2].equals([1,2]));assertFalse([1,2].equals([2,1]));assertFalse([1,2].equals([1,2,3]));assertTrue(new Date("2011-03-31").equals(new Date("2011-03-31")));assertFalse(new Date("2011-03-31").equals(new Date("1970-01-01")));
assertTrue({}.equals({}));assertTrue({a:1,b:2}.equals({a:1,b:2}));assertTrue({a:1,b:2}.equals({b:2,a:1}));assertFalse({a:1,b:2}.equals({a:1,b:3}));
assertTrue({1:{name:"mhc",age:28}, 2:{name:"arb",age:26}}.equals({1:{name:"mhc",age:28}, 2:{name:"arb",age:26}}));assertFalse({1:{name:"mhc",age:28}, 2:{name:"arb",age:26}}.equals({1:{name:"mhc",age:28}, 2:{name:"arb",age:27}}));
var a = {a: 'text', b:[0,1]};var b = {a: 'text', b:[0,1]};var c = {a: 'text', b: 0};var d = {a: 'text', b: false};var e = {a: 'text', b:[1,0]};var i = {a: 'text',c: {b: [1, 0]}};var j = {a: 'text',c: {b: [1, 0]}};var k = {a: 'text', b: null};var l = {a: 'text', b: undefined};
assertTrue(a.equals(b));assertFalse(a.equals(c));assertFalse(c.equals(d));assertFalse(a.equals(e));assertTrue(i.equals(j));assertFalse(d.equals(k));assertFalse(k.equals(l));
// from comments on stackoverflow postassert.isFalse(objectEquals([1, 2, undefined], [1, 2]));assert.isFalse(objectEquals([1, 2, 3], { 0: 1, 1: 2, 2: 3 }));assert.isFalse(objectEquals(new Date(1234), 1234));
// no two different function is equal really, they capture their context variables// so even if they have same toString(), they won't have same functionalityvar func = function (x) { return true; };var func2 = function (x) { return true; };assert.isTrue(objectEquals(func, func));assert.isFalse(objectEquals(func, func2));assert.isTrue(objectEquals({ a: { b: func } }, { a: { b: func } }));assert.isFalse(objectEquals({ a: { b: func } }, { a: { b: func2 } }));
Object::equals = (other) ->typeOf = Object::toString
return false if typeOf.call(this) isnt typeOf.call(other)return `this == other` unless typeOf.call(other) is '[object Object]' ortypeOf.call(other) is '[object Array]'
(return false unless this[key].equals other[key]) for key, value of this(return false if typeof this[key] is 'undefined') for key of other
true
以下是测试:
describe "equals", ->
it "should consider two numbers to be equal", ->assert 5.equals(5)
it "should consider two empty objects to be equal", ->assert {}.equals({})
it "should consider two objects with one key to be equal", ->assert {a: "banana"}.equals {a: "banana"}
it "should consider two objects with keys in different orders to be equal", ->assert {a: "banana", kendall: "garrus"}.equals {kendall: "garrus", a: "banana"}
it "should consider two objects with nested objects to be equal", ->assert {a: {fruit: "banana"}}.equals {a: {fruit: "banana"}}
it "should consider two objects with nested objects that are jumbled to be equal", ->assert {a: {a: "banana", kendall: "garrus"}}.equals {a: {kendall: "garrus", a: "banana"}}
it "should consider two objects with arrays as values to be equal", ->assert {a: ["apple", "banana"]}.equals {a: ["apple", "banana"]}
it "should not consider an object to be equal to null", ->assert !({a: "banana"}.equals null)
it "should not consider two objects with different keys to be equal", ->assert !({a: "banana"}.equals {})
it "should not consider two objects with different values to be equal", ->assert !({a: "banana"}.equals {a: "grapefruit"})
//Returns the object's class, Array, Date, RegExp, Object are of interest to usvar getClass = function(val) {return Object.prototype.toString.call(val).match(/^\[object\s(.*)\]$/)[1];};
//Defines the type of the value, extended typeofvar whatis = function(val) {
if (val === undefined)return 'undefined';if (val === null)return 'null';
var type = typeof val;
if (type === 'object')type = getClass(val).toLowerCase();
if (type === 'number') {if (val.toString().indexOf('.') > 0)return 'float';elsereturn 'integer';}
return type;};
var compareObjects = function(a, b) {if (a === b)return true;for (var i in a) {if (b.hasOwnProperty(i)) {if (!equal(a[i],b[i])) return false;} else {return false;}}
for (var i in b) {if (!a.hasOwnProperty(i)) {return false;}}return true;};
var compareArrays = function(a, b) {if (a === b)return true;if (a.length !== b.length)return false;for (var i = 0; i < a.length; i++){if(!equal(a[i], b[i])) return false;};return true;};
var _equal = {};_equal.array = compareArrays;_equal.object = compareObjects;_equal.date = function(a, b) {return a.getTime() === b.getTime();};_equal.regexp = function(a, b) {return a.toString() === b.toString();};// uncoment to support function as string compare// _equal.fucntion = _equal.regexp;
/** Are two values equal, deep compare for objects and arrays.* @param a {any}* @param b {any}* @return {boolean} Are equal?*/var equal = function(a, b) {if (a !== b) {var atype = whatis(a), btype = whatis(b);
if (atype === btype)return _equal.hasOwnProperty(atype) ? _equal[atype](a, b) : a==b;
return false;}
return true;};
a = {foo:{bar:1}}b = {foo:{bar:1}}c = {foo:{bar:2}}
var rusDiff = require('rus-diff').rusDiff
console.log(rusDiff(a, b)) // -> false, meaning a and b are equalconsole.log(rusDiff(a, c)) // -> { '$set': { 'foo.bar': 2 } }
var john = {occupation: "Web Developer",age: 25};
var bobby = {occupation: "Web Developer",age: 25};
function isEquivalent(a, b) {// Create arrays of property names
var aProps = Object.getOwnPropertyNames(a);var bProps = Object.getOwnPropertyNames(b);
// If number of properties is different, objects are not equivalent
if (aProps.length != bProps.length) {return false;}
for (var i = 0; i < aProps.length; i++) {var propName = aProps[i];
// If values of same property are not equal, objects are not equivalentif (a[propName] !== b[propName]) {return false;}}
// If we made it this far, objects are considered equivalentreturn true;}
// Outputs: trueconsole.log(isEquivalent(john, bobby));
var john = {occupation: "Web Developer",age: 25};
var bobby = {occupation: "Web Developer",age: 25};
// Outputs: trueconsole.log(_.isEqual(john, bobby));
////////////////////////////////////////////////////////////////////////////////
var equals = function ( objectA, objectB ) {var result = false,keysA,keysB;
// Check if they are pointing at the same variable. If they are, no need to test further.if ( objectA === objectB ) {return true;}
// Check if they are the same type. If they are not, no need to test further.if ( typeof objectA !== typeof objectB ) {return false;}
// Check what kind of variables they are to see what sort of comparison we should make.if ( typeof objectA === "object" ) {// Check if they have the same constructor, so that we are comparing apples with apples.if ( objectA.constructor === objectA.constructor ) {// If we are working with Arrays...if ( objectA instanceof Array ) {// Check the arrays are the same length. If not, they cannot be the same.if ( objectA.length === objectB.length ) {// Compare each element. They must be identical. If not, the comparison stops immediately and returns false.return objectA.every(function ( element, i ) {return equals( element, objectB[ i ] );});}// They are not the same length, and so are not identical.else {return false;}}// If we are working with RegExps...else if ( objectA instanceof RegExp ) {// Return the results of a string comparison of the expression.return ( objectA.toString() === objectB.toString() );}// Else we are working with other types of objects...else {// Get the keys as arrays from both objects. This uses Object.keys, so no old browsers here.keysA = Object.keys( objectA );
keysB = Object.keys( objectB );
// Check the key arrays are the same length. If not, they cannot be the same.if ( keysA.length === keysB.length ) {// Compare each property. They must be identical. If not, the comparison stops immediately and returns false.return keysA.every(function ( element ) {return equals( objectA[ element ], objectB[ element ] );});}// They do not have the same number of keys, and so are not identical.else {return false;}}}// They don't have the same constructor.else {return false;}}// If they are both functions, let us do a string comparison.else if ( typeof objectA === "function" ) {return ( objectA.toString() === objectB.toString() );}// If a simple variable type, compare directly without coercion.else {return ( objectA === objectB );}
// Return a default if nothing has already been returned.return result;};
////////////////////////////////////////////////////////////////////////////////
function areEqual(obj1, obj2) {var a = JSON.stringify(obj1), b = JSON.stringify(obj2);if (!a) a = '';if (!b) b = '';return (a.split('').sort().join('') == b.split('').sort().join(''));}
/** Recursively check if both objects are equal in value****** This function is designed to use multiple methods from most probable*** (and in most cases) valid, to the more regid and complex method.****** One of the main principles behind the various check is that while*** some of the simpler checks such as == or JSON may cause false negatives,*** they do not cause false positives. As such they can be safely run first.****** # !Important Note:*** as this function is designed for simplified deep equal checks it is not designed*** for the following****** - Class equality, (ClassA().a = 1) maybe valid to (ClassB().b = 1)*** - Inherited values, this actually ignores them*** - Values being strictly equal, "1" is equal to 1 (see the basic equality check on this)*** - Performance across all cases. This is designed for high performance on the*** most probable cases of == / JSON equality. Consider bench testing, if you have*** more 'complex' requirments****** @param objA : First object to compare*** @param objB : 2nd object to compare*** @param .... : Any other objects to compare****** @returns true if all equals, or false if invalid****** @license Copyright by eugene@picoded.com, 2012.*** Licensed under the MIT license: http://opensource.org/licenses/MIT**/function simpleRecusiveDeepEqual(objA, objB) {// Multiple comparision check//--------------------------------------------var args = Array.prototype.slice.call(arguments);if(args.length > 2) {for(var a=1; a<args.length; ++a) {if(!simpleRecusiveDeepEqual(args[a-1], args[a])) {return false;}}return true;} else if(args.length < 2) {throw "simpleRecusiveDeepEqual, requires atleast 2 arguments";}
// basic equality check,//--------------------------------------------// if this succed the 2 basic values is equal,// such as numbers and string.//// or its actually the same object pointer. Bam//// Note that if string and number strictly equal is required// change the equality from ==, to ===//if(objA == objB) {return true;}
// If a value is a bsic type, and failed above. This failsvar basicTypes = ["boolean", "number", "string"];if( basicTypes.indexOf(typeof objA) >= 0 || basicTypes.indexOf(typeof objB) >= 0 ) {return false;}
// JSON equality check,//--------------------------------------------// this can fail, if the JSON stringify the objects in the wrong order// for example the following may fail, due to different string order://// JSON.stringify( {a:1, b:2} ) == JSON.stringify( {b:2, a:1} )//if(JSON.stringify(objA) == JSON.stringify(objB)) {return true;}
// Array equality check//--------------------------------------------// This is performed prior to iteration check,// Without this check the following would have been considered valid//// simpleRecusiveDeepEqual( { 0:1963 }, [1963] );//// Note that u may remove this segment if this is what is intended//if( Array.isArray(objA) ) {//objA is array, objB is not an arrayif( !Array.isArray(objB) ) {return false;}} else if( Array.isArray(objB) ) {//objA is not array, objB is an arrayreturn false;}
// Nested values iteration//--------------------------------------------// Scan and iterate all the nested values, and check for non equal values recusively//// Note that this does not check against null equality, remove the various "!= null"// if this is required
var i; //reuse var to iterate
// Check objA values against objBfor (i in objA) {//Protect against inherited propertiesif(objA.hasOwnProperty(i)) {if(objB.hasOwnProperty(i)) {// Check if deep equal is validif(!simpleRecusiveDeepEqual( objA[i], objB[i] )) {return false;}} else if(objA[i] != null) {//ignore null values in objA, that objB does not have//else failsreturn false;}}}
// Check if objB has additional values, that objA do not, fail if sofor (i in objB) {if(objB.hasOwnProperty(i)) {if(objB[i] != null && !objA.hasOwnProperty(i)) {//ignore null values in objB, that objA does not have//else failsreturn false;}}}
// End of all checks//--------------------------------------------// By reaching here, all iteration scans have been done.// and should have returned false if it failedreturn true;}
// Sanity checking of simpleRecusiveDeepEqual(function() {if(// Basic checks!simpleRecusiveDeepEqual({}, {}) ||!simpleRecusiveDeepEqual([], []) ||!simpleRecusiveDeepEqual(['a'], ['a']) ||// Not strict checks!simpleRecusiveDeepEqual("1", 1) ||// Multiple objects check!simpleRecusiveDeepEqual( { a:[1,2] }, { a:[1,2] }, { a:[1,2] } ) ||// Ensure distinction between array and object (the following should fail)simpleRecusiveDeepEqual( [1963], { 0:1963 } ) ||// Null strict checkssimpleRecusiveDeepEqual( 0, null ) ||simpleRecusiveDeepEqual( "", null ) ||// Last "false" exists to make the various check above easy to comment in/outfalse) {alert("FATAL ERROR: simpleRecusiveDeepEqual failed basic checks");} else {//added this last line, for SO snippet alert on successalert("simpleRecusiveDeepEqual: Passed all checks, Yays!");}})();
function deepEqual (first, second) {// Not equal if either is not an object or is null.if (!isObject(first) || !isObject(second) ) return false;
// If properties count is differentif (keys(first).length != keys(second).length) return false;
// Return false if any property value is different.for(prop in first){if (first[prop] != second[prop]) return false;}return true;}
// Checks if argument is an object and is not nullfunction isObject(obj) {return (typeof obj === "object" && obj != null);}
// returns arrays of object keysfunction keys (obj) {result = [];for(var key in obj){result.push(key);}return result;}
// Some test codeobj1 = {name: 'Singh',age: 20}
obj2 = {age: 20,name: 'Singh'}
obj3 = {name: 'Kaur',age: 19}
console.log(deepEqual(obj1, obj2));console.log(deepEqual(obj1, obj3));
const arraysEqual = (a, b) => {if (a === b)return true;if (a === null || b === null)return false;if (a.length !== b.length)return false;
// If you don't care about the order of the elements inside// the array, you should sort both arrays here.
for (let i = 0; i < a.length; ++i) {if (a[i] !== b[i])return false;}return true;};
const jsonsEqual = (a, b) => {
if(typeof a !== 'object' || typeof b !== 'object')return false;
if (Object.keys(a).length === Object.keys(b).length) { // if items have the same sizelet response = true;
for (let key in a) {if (!b[key]) // if not keyresponse = false;if (typeof a[key] !== typeof b[key]) // if typeof doesn't equalsresponse = false;else {if (Array.isArray(a[key])) // if arrayresponse = arraysEqual(a[key], b[key]);else if (typeof a[key] === 'object') // if another jsonresponse = jsonsEqual(a[key], b[key]);else if (a[key] !== b[key]) // not equalsresponse = false;}if (!response) // return if one item isn't equalreturn false;}} elsereturn false;
return true;};
const json1 = {a: 'a',b: 'asd',c: ['1',2,2.5,'3',{d: 'asd',e: [1.6,{f: 'asdasd',g: '123'}]}],h: 1,i: 1.2,};
const json2 = {a: 'nops',b: 'asd'};
const json3 = {a: 'h',b: '484',c: [3,4.5,'2ss',{e: [{f: 'asdasd',g: '123'}]}],h: 1,i: 1.2,};
const result = jsonsEqual(json1,json2);//const result = jsonsEqual(json1,json3);//const result = jsonsEqual(json1,json1);
if(result) // is equal$('#result').text("Jsons are the same")else$('#result').text("Jsons aren't equals")
var object1 = {key: "value"};
var object2 = {key: "value"};
var object3 = {key: "no value"};
console.log('object1 and object2 are equal: ', JSON.stringify(object1) === JSON.stringify(object2));
console.log('object2 and object3 are equal: ', JSON.stringify(object2) === JSON.stringify(object3));
let objectOne = { hey, you }let objectTwo = { you, hey }
// If you really wanted you could make this recursive for deep sort.const sortObjectByKeyname = (objectToSort) => {return Object.keys(objectToSort).sort().reduce((r, k) => (r[k] = objectToSort[k], r), {});}
let objectOne = sortObjectByKeyname(objectOne)let objectTwo = sortObjectByKeyname(objectTwo)
let user1 = {name: "John",address: {line1: "55 Green Park Road",line2: {a:[1,2,3]}},email:null}
let user2 = {name: "John",address: {line1: "55 Green Park Road",line2: {a:[1,2,3]}},email:null}
// Method 1
function isEqual(a, b) {return JSON.stringify(a) === JSON.stringify(b);}
// Method 2
function isEqual(a, b) {// checking type of a And bif(typeof a !== 'object' || typeof b !== 'object') {return false;}
// Both are NULLif(!a && !b ) {return true;} else if(!a || !b) {return false;}
let keysA = Object.keys(a);let keysB = Object.keys(b);if(keysA.length !== keysB.length) {return false;}for(let key in a) {if(!(key in b)) {return false;}
if(typeof a[key] === 'object') {if(!isEqual(a[key], b[key])){return false;}} else {if(a[key] !== b[key]) {return false;}}}
return true;}
console.log(isEqual(user1,user2));
const one={name:'mohit' , age:30};//const two ={name:'mohit',age:30};const two ={age:30,name:'mohit'};
function isEquivalent(a, b) {// Create arrays of property namesvar aProps = Object.getOwnPropertyNames(a);var bProps = Object.getOwnPropertyNames(b);
// If number of properties is different,// objects are not equivalentif (aProps.length != bProps.length) {return false;}
for (var i = 0; i < aProps.length; i++) {var propName = aProps[i];
// If values of same property are not equal,// objects are not equivalentif (a[propName] !== b[propName]) {return false;}}
// If we made it this far, objects// are considered equivalentreturn true;}
console.log(isEquivalent(one,two))
function isEquivalent(a, b) {// Create arrays of property namesvar aProps = Object.getOwnPropertyNames(a);var bProps = Object.getOwnPropertyNames(b);
// If number of properties is different, objects are not equivalentif (aProps.length != bProps.length) {return false;}
for (var i = 0; i < aProps.length; i++) {var propName = aProps[i];
// If values of same property are not equal, objects are not equivalentif (a[propName] !== b[propName]) {return false;}}
// If we made it this far, objects are considered equivalentreturn true; }
// this comparison would not work for function and symbol comparisons// this would only work best for compared objects that do not belong to same address in memory// Returns true if there is no difference, and false otherwise
export const isObjSame = (obj1, obj2) => {if (typeof obj1 !== "object" && obj1 !== obj2) {return false;}
if (typeof obj1 !== "object" && typeof obj2 !== "object" && obj1 === obj2) {return true;}
if (typeof obj1 === "object" && typeof obj2 === "object") {if (Array.isArray(obj1) && Array.isArray(obj2)) {if (obj1.length === obj2.length) {if (obj1.length === 0) {return true;}const firstElemType = typeof obj1[0];
if (typeof firstElemType !== "object") {const confirmSameType = currentType =>typeof currentType === firstElemType;
const checkObjOne = obj1.every(confirmSameType);const checkObjTwo = obj2.every(confirmSameType);
if (checkObjOne && checkObjTwo) {// they are primitves, we can therefore sort before and compare by index// use number sort// use alphabet sort// use regular sortif (firstElemType === "string") {obj1.sort((a, b) => a.localeCompare(b));obj2.sort((a, b) => a.localeCompare(b));}obj1.sort((a, b) => a - b);obj2.sort((a, b) => a - b);
let equal = true;
obj1.map((element, index) => {if (!isObjSame(element, obj2[index])) {equal = false;}});
return equal;}
if ((checkObjOne && !checkObjTwo) ||(!checkObjOne && checkObjTwo)) {return false;}
if (!checkObjOne && !checkObjTwo) {for (let i = 0; i <= obj1.length; i++) {const compareIt = isObjSame(obj1[i], obj2[i]);if (!compareIt) {return false;}}
return true;}
// if()}const newValue = isObjSame(obj1, obj2);return newValue;} else {return false;}}
if (!Array.isArray(obj1) && !Array.isArray(obj2)) {let equal = true;if (obj1 && obj2) {const allKeys1 = Array.from(Object.keys(obj1));const allKeys2 = Array.from(Object.keys(obj2));
if (allKeys1.length === allKeys2.length) {allKeys1.sort((a, b) => a - b);allKeys2.sort((a, b) => a - b);
allKeys1.map((key, index) => {if (key.toLowerCase() !== allKeys2[index].toLowerCase()) {equal = false;return;}
const confirmEquality = isObjSame(obj1[key], obj2[key]);
if (!confirmEquality) {equal = confirmEquality;return;}});}}
return equal;
// return false;}}};
function genObjStr(obj, settings) {// Generate a string that corresponds to an object guarenteed to be the same str even if// the object have different ordering. The string would largely be used for comparison purposes
var settings = settings||{};var doStripWhiteSpace = defTrue(settings.doStripWhiteSpace);var doSetLowerCase = settings.doSetLowerCase||false;
if(isArray(obj)) {var vals = [];for(var i = 0; i < obj.length; ++i) {vals.push(genObjStr(obj[i], settings));}vals = arraySort(vals);return vals.join(`,`);
} else if(isObject(obj)) {
var keys = Object.keys(obj);keys = arraySort(keys);
var vals = [];for(var key of keys) {
var value = obj[key];
value = genObjStr(value, settings);
if(doStripWhiteSpace) {key = removeWhitespace(key);var value = removeWhitespace(value);};if(doSetLowerCase) {key = key.toLowerCase();value = value.toLowerCase();}
vals.push(value);}var str = JSON.stringify({keys: keys, vals: vals});return str} else {if(doStripWhiteSpace) {obj = removeWhitespace(obj);};if(doSetLowerCase) {obj = obj.toLowerCase();}return obj}
}
var obj1 = {foo: 123, bar: `Test`};var obj2 = {bar: `Test`, foo: 123};
console.log(genObjStr(obj1) == genObjStr(obj1))