Skip to content

Instantly share code, notes, and snippets.

@hara-y-u
Created October 18, 2011 09:56
Show Gist options
  • Save hara-y-u/1295074 to your computer and use it in GitHub Desktop.
Save hara-y-u/1295074 to your computer and use it in GitHub Desktop.
push to array recursively
function recursivePush(arr, val) {
var execPush = false;
arr.forEach(function(_v) {
if(_v instanceof Array) {
recursivePush(_v, val);
} else {
execPush = true;
}
});
if(execPush || !arr.length) { arr.push(val); };
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment