Member-only story
How to Use Spread in JavaScript Functions
Learn about the JavaScript spread operator in functions

What is spread?
The spread operator was introduced by ES6 it consists of three dots (…). Depending on where and how you use spread you can achieve a number of things. The three main uses for spread are within functions, objects, and arrays. Most definitions of spread state that it allows you to expand an iterable to another place such as a variable. An iterable is a data structure that you can iterate over. For example, when we loop through each element within an array we are iterating over the array.
Why do we use spread?
JavaScript has a set of methods attached to the build-in Math object which let us find the minimum and maximum number from a set of values passed in when we use the methods. These are Math.max() and Math.min(). If we wanted to find the minimum value from a set of numbers we could use the Math.min() method. Let’s take a look at how this works.
Math.min(10, 9, 8, 7);//Returns ---> 7
In the above example, we use the Math.min() method and pass it to the function calling four individual arguments, under the hood JavaScript iterates through these values and returns the lowest value. This is…