When coming from the Java world one has to get used to functions in JavaScript, where appropriate, can take any number of parameters. This is because it’s a language feature (MDN).

Recently I noticed this using the push function of the array type.

So you can replace the following three lines :

var numbers = [];
numbers.push(1);
numbers.push(2);
numbers.push(3);

simply with this:

var numbers = [];
numbers.push(1, 2, 3);

Developer since the 80'th, working at Forschungszentrum Jülich (http://www.fz-juelich.de) …

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store