Clone an array - Node.js Array

Node.js examples for Array:Array Operation

Description

Clone an array

Demo Code

Array.prototype.clone = function () {
    //return this.filter(function () { return true });
    var arr = [];
    for (var i = 0, len = this.length; i < len; i++) arr[i] = this[i];
    return arr;//w  w  w .j  av  a  2 s .  c o m
}

Related Tutorials