var list = [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]; var res = [], first = true; while ( list.length ) { res.push( first ? list.shift() : list.pop() ); first = !first; } alert( res )