This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// correct object cloning | |
function clone(obj, fields) { | |
if (null == obj || "object" != typeof obj) return obj; | |
if (obj.constructor == File && obj.size) | |
return obj | |
var copy = obj.constructor(); | |
if (fields){ | |
for (let i of fields) | |
if (obj.hasOwnProperty(i)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function deepEq( x, y, propertyList, pred ) { | |
if ( x === y ) return true; | |
// if both x and y are null or undefined and exactly the same | |
if ( ! ( x instanceof Object ) || ! ( y instanceof Object ) ) return false; | |
// if they are not strictly equal, they both need to be Objects | |
if ( x.constructor !== y.constructor ) return false; | |
// they must have the exact same prototype chain, the closest we can do is | |
// test there constructor. |
OlderNewer