1
// +----------------------------------------------------------------+
2
// | Array functions that are missing in IE 5.0 |
3
// | Author: Cezary Tomczak [www.gosu.pl] |
4
// | Free for any use as long as all copyright messages are intact. |
5
// +----------------------------------------------------------------+
7
// Removes the last element from an array and returns that element.
8
if (!Array.prototype.pop) {
9
Array.prototype.pop = function() {
12
last = this[this.length - 1];
19
// Adds one or more elements to the end of an array and returns the new length of the array.
20
if (!Array.prototype.push) {
21
Array.prototype.push = function() {
22
for (var i = 0; i < arguments.length; ++i) {
23
this[this.length] = arguments[i];
29
// Removes the first element from an array and returns that element.
30
if (!Array.prototype.shift) {
31
Array.prototype.shift = function() {
35
for (var i = 0; i < this.length - 1; ++i) {
36
this[i] = this[i + 1];
44
// Adds one or more elements to the front of an array and returns the new length of the array.
45
if (!Array.prototype.unshift) {
46
Array.prototype.unshift = function() {
47
if (arguments.length) {
48
var i, len = arguments.length;
49
for (i = this.length + len - 1; i >= len; --i) {
50
this[i] = this[i - len];
52
for (i = 0; i < len; ++i) {
53
this[i] = arguments[i];
60
// Adds and/or removes elements from an array.
61
if (!Array.prototype.splice) {
62
Array.prototype.splice = function(index, howMany) {
63
var elements = [], removed = [], i;
64
for (i = 2; i < arguments.length; ++i) {
65
elements.push(arguments[i]);
67
for (i = index; (i < index + howMany) && (i < this.length); ++i) {
68
removed.push(this[i]);
70
for (i = index + howMany; i < this.length; ++i) {
71
this[i - howMany] = this[i];
73
this.length -= removed.length;
74
for (i = this.length + elements.length - 1; i >= index + elements.length; --i) {
75
this[i] = this[i - elements.length];
77
for (i = 0; i < elements.length; ++i) {
78
this[index + i] = elements[i];
b'\\ No newline at end of file'