FANDOM


function array_merge(arr) {
	var merged = arr;
	for (var i = 1; i < arguments.length; i++) {
		merged = merged.concat(arguments[i]);
	}
	return merged;
}

In some situations is better use:

function array_merge() 
{
	var merged = new Array();
	for( var i = 0; i < arguments.length; i++ )
	{
		for( var j = 0; j < arguments[i].length; j++ )
		{
			merged = merged.concat( arguments[i][j] );
		}
	}
	return merged;
}


Example Javascript UsageEdit

arr1 = new Array("dog", "cat", "mouse");
arr2 = new Array("lion", "tiger", "bear");
arr3 = new Array("rabbit", "buck", "snake");
arr4 = array_merge(arr1, arr2, arr3);
alert(arr4); /* Gives:  dog,cat,mouse,lion,tiger,bear,rabbit,buck,snake  */

The usage is same for both functions.

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.