X-Git-Url: http://git.roojs.org/?a=blobdiff_plain;f=Array.js;h=a3b684d73e3b0d28b3aac55260f907e9de402f4d;hb=242e8cb7d4eb31741bfb8d282303ac36f54dd00e;hp=ed3a095cec723c453a61aa40fb63775b15aeeefb;hpb=73b47405136af9942619556e354d52a9881b8438;p=roojs1 diff --git a/Array.js b/Array.js index ed3a095cec..a3b684d73e 100644 --- a/Array.js +++ b/Array.js @@ -49,13 +49,40 @@ Roo.applyIf(Array.prototype, { var thisp = arguments[1]; for (var i = 0; i < len; i++) { - if (i in this) + if (i in this) { res[i] = fun.call(thisp, this[i], i, this); + } } return res; + }, + /** + * equals + * @param {Array} o The array to compare to + * @returns {Boolean} true if the same + */ + equals : function(b) + { + // https://stackoverflow.com/questions/3115982/how-to-check-if-two-arrays-are-equal-with-javascript + if (this === b) { + return true; + } + if (b == null) { + return false; + } + if (this.length !== b.length) { + return false; + } + + // sort?? a.sort().equals(b.sort()); + + for (var i = 0; i < this.length; ++i) { + if (this[i] !== b[i]) { + return false; + } + } + return true; } - });