Skip to content

Instantly share code, notes, and snippets.

/*
* Flatten a multidimentional array of integers to a single dimention with the integer values
*/
function flatten_array(arr) {
var newArr = []
for (var idx=0; idx<arr.length; idx++) {
if (Array.isArray(arr[idx])) {
var a = flatten_array(arr[idx]);
for (var i=0; i<a.length; i++) {
newArr.push(a[i]);