Javascript Array reverseElements()

Description

Javascript Array reverseElements()


"use strict";//from w w  w. j  ava 2 s .  c  o  m

Array.prototype.reverseElements = function () {
    var temp = this.concat();
    var i = this.length - 1;
    var target = this.length - 1;

    while (i >= 0) {
        this[target - i] = temp[i];
        i--;
    }

    return this;
}



PreviousNext

Related