Most efficient way to prepend a value to an array
I’m not sure about more efficient in terms of big-O but certainly using the unshift method is more concise: var a = [1, 2, 3, 4]; a.unshift(0); // => [0, 1, 2, 3, 4] console.log({a}); [Edit] This jsPerf benchmark shows that unshift is decently faster in at least a couple of browsers, regardless of possibly … Read more