r9714 - helma-ng/trunk/modules/core
[email protected] Wed, 6 May 2009 17:25:14 +0200 (CEST)
| Newsgroups | gmane.comp.java.helma.cvs |
|---|---|
| Message-ID | <20090506152514.2D3913D0D6@mia> |
Author: hannes
Date: 2009-05-06 17:25:14 +0200 (Wed, 06 May 2009)
New Revision: 9714
Modified:
helma-ng/trunk/modules/core/array.js
Log:
Add Array.prototype.remove(val)
Details at http://dev.helma.org/trac/helma/changeset/9714
Modified: helma-ng/trunk/modules/core/array.js
===================================================================
--- helma-ng/trunk/modules/core/array.js 2009-05-06 13:16:26 UTC (rev 9713)
+++ helma-ng/trunk/modules/core/array.js 2009-05-06 15:25:14 UTC (rev 9714)
@@ -39,6 +39,23 @@
});
/**
+ * Remove the first occurrence of the argument value from this array. This method
+ * mutates and returns the array on which it is called and does not create a
+ * new array instance.
+ * @param {Object} val the value to remove
+ * @return {Array} this array
+ */
+Object.defineProperty(Array.prototype, "remove", {
+ value: function(val) {
+ var index = this.indexOf(val);
+ if(index > -1) {
+ this.splice(index, 1);
+ }
+ return this;
+ }
+})
+
+/**
* Retrieve the union set of a bunch of arrays
* @param {Array} array1,... the arrays to unify
* @return {Array} the union set