Skip to content

Instantly share code, notes, and snippets.

View farhatnawaz's full-sized avatar

Farhat Nawaz farhatnawaz

View GitHub Profile
@farhatnawaz
farhatnawaz / flatten.js
Created June 21, 2017 19:26
This piece of code flattens the nested arrays
function flatten(array) {
var idx,
temp = [array],
lastIdx = [-1],
result = [];
while(temp.length) {
array = temp.pop();
idx = lastIdx.pop() + 1;