Forum Moderators: open
[dithered.com...]
You need to roll your own and add them to the Array.prototype . Incomplete emulations are easy, but making sure you have all possibilities covered is trickier.
I'm going to let someone else take the credit (and the blame):
I have also posted the full code listing for other array method emulations)
// +----------------------------------------------------------------+
// ¦ Array functions that are missing in IE 5.0 ¦
// ¦ Author: Cezary Tomczak [www.gosu.pl] ¦
// ¦ Free for any use as long as all copyright messages are intact. ¦
// +----------------------------------------------------------------+// Removes the last element from an array
// and returns that element.
if (!Array.prototype.pop) {
Array.prototype.pop = function() {
var last;
if (this.length) {
last = this[this.length - 1];
this.length -= 1;
}
return last¦¦null;
};
}// Adds one or more elements to the end of an array and returns
// the new length of the array.
if (!Array.prototype.push) {
Array.prototype.push = function() {
for (var i = 0; i < arguments.length; ++i) {
this[this.length] = arguments[i];
}
return this.length;
};
}
[edited by: jatar_k at 3:46 pm (utc) on Oct. 5, 2005]