Combines two Arrays - Node.js Array

Node.js examples for Array:Array Operation

Description

Combines two Arrays

Demo Code

/**//from  w  w w . j  a  v a 2s  .c  om
 * combines two Arrays
 *
 * @param {Array} arr
 *          Array object
 *
 * @return {Array} new merged Array object
 *
 */
Array.prototype.merge = function(arr, bShuffle) {
    var type = Object.prototype.toString.call(this).split(/\W/)[2];
    if (type === 'Array') {
        var output = this.concat(arr);
        return output;
    }
};

Related Tutorials