1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-06-14 09:36:48 +00:00

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.
This commit is contained in:
Devin Weaver 2014-04-25 08:42:45 -04:00
parent 8611867930
commit 540681b2bc

View File

@ -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
tag: tag name