let a = [ 'three', 'four', 'five' ]; // Start with an example array a.unshift('zero'); // prepend just one element a.unshift(['one', 'two']); // prepend an array at the start
Programming Tips - javaScript: prepend (add at the start) at the start of an array
Date: 2016apr17
Updated: 2023mar30
Language: javaScript
Keywords: append, efficient
Q. javaScript: prepend (add at the start) at the start of an array
A. Use unshift() like this: