Array map() Method In JavaScript

The map() method in JavaScript creates an array by calling a specific function on each element present in the parent array. It is a non-mutating method. Generally map() method is used to iterate over an array and calling function on every element of array. Syntax: array.map(function(currentValue, index, arr), thisValue) Parameters: This method accepts two parameters as mentioned above and described below: function(currentValue, index, arr): It is required parameter and it runs on each element of array. It contains three parameters which are listed below: currentValue: It is

Read more

What are Rest parameters in JavaScript ?

The rest parameter syntax allows a function to accept an indefinite number of arguments as an array, providing a way to represent variadic functions in JavaScript. Now, What is variadic function ? In mathematics and in computer programming, a variadic function is a function of indefinite arity, i.e., one which accepts a variable number of arguments. Support for variadic functions differs widely among programming languages. What is Rest parameter A function definition’s last parameter can be prefixed with “…” , which will cause all remaining (user supplied) parameters to be placed within a “standard” JavaScript

Read more