kopia lustrzana https://github.com/miklobit/TiddlyWiki5
Add $tw.util.isEqual
This checks to see if an array is equal. Should handle case where an array is considered null or undefined. It short circuits when the lengths are different and will only loop when needed.print-window-tiddler
rodzic
8611867930
commit
540681b2bc
12
boot/boot.js
12
boot/boot.js
|
@ -85,6 +85,18 @@ $tw.utils.each = function(object,callback) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
Check if an array is equal by value and by reference.
|
||||||
|
*/
|
||||||
|
$tw.utils.isEqual = function(array1,array2) {
|
||||||
|
if(array1 === array2) { return true; }
|
||||||
|
array1 = array1 || []; array2 = array2 || [];
|
||||||
|
if(array1.length !== array2.length) { return false; }
|
||||||
|
return array1.every(function(value,index) {
|
||||||
|
return value === array2[index];
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Helper for making DOM elements
|
Helper for making DOM elements
|
||||||
tag: tag name
|
tag: tag name
|
||||||
|
|
Ładowanie…
Reference in New Issue