mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2025-02-22 14:00:03 +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:
parent
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
|
||||
tag: tag name
|
||||
|
Loading…
x
Reference in New Issue
Block a user