JavaScript Array map() method17 Mar 2025 | 1 min read The JavaScript array map() method calls the specified function for every array element and returns the new array. This method doesn't change the original array. SyntaxThe map() method is represented by the following syntax: Parametercallback - It represents the function that produces the new array. currentvalue - The current element of array. index - It is optional. The index of current element. arr - It is optional. The array on which map() method operated. thisArg - It is optional. The value to use as this while executing callback. ReturnA new array whose each element generate from the result of a callback function. JavaScript Array map() method exampleLet's see some examples of map() method. Example 1Here, map() method returns the round of given elements to the nearest integer. Test it NowOutput: 2,4,5 Example 2Here, map() method returns every element of given array by multiplying it by 3. Test it NowOutput: 6,12,18 Next TopicJavaScript Array |
JavaScript Array method The JavaScript array method extracts the part of the given array and returns it. This method doesn't change the original array. Syntax The method is represented by the following syntax: array.slice(start,end) Parameter start - It is optional. It represents the index from where the method...
1 min read
JavaScript Array Method The JavaScript array method combines two or more arrays and returns a new string. This method doesn't make any change in the original array. Syntax The method is represented by the following syntax: array.concat(arr1,arr2,....,arrn) Parameter arr1,arr2,....,arrn - It represent the arrays to be combined. Return A new...
1 min read
JavaScript Array copyWithin() method The JavaScript array copyWithin() method copies the part of the given array with its own elements and returns the modified array. This method doesn't change the length of the modified array. Syntax The copyWithin() method is represented by the following syntax: array.copyWithin(target, start, end) Parameter target -...
1 min read
JavaScript Array Method The method creates a new array iterator object that carries the values specified at each array index. We can iterate the array elements via loops or iterator methods. Syntax array.; Parameter It does not hold any parameter as such. Return It creates and returns a newly created...
2 min read
JavaScript Array method The JavaScript array method adds one or more elements in the beginning of the given array and returns the updated array. This method changes the length of the original array. Syntax The method is represented by the following syntax: array. unshift(element1,element2,....,elementn) Parameter element1,element2,....,elementn - The...
1 min read
JavaScript Array method The JavaScript array method is used to search the position of a particular element in a given array. It behaves similar to indexOf() method with a difference that it start searching an element from the last position of an array. The ...
1 min read
JavaScript Array method The JavaScript array method changes the sequence of elements of the given array and returns the reverse sequence. In other words, the arrays last element becomes first and the first element becomes the last. This method also made the changes in...
1 min read
JavaScript Array method The JavaScript array method filter and extract the element of an array that satisfying the provided condition. It doesn't change the original array. Syntax The method is represented by the following syntax: array.filter(callback(currentvalue,index,arr),thisArg) Parameter callback - It represents the function that test the condition. currentvalue -...
1 min read
JavaScript Array method The JavaScript array method combines all the elements of an array into a string and return a new string. We can use any type of separators to separate given array elements. Syntax The method is represented by the following syntax: array.join(separator) Parameter Separator() - It...
1 min read
JavaScript Array Method The method creates and returns a new array from different a number of arguments. It does not focus on the type and number of arguments. Similar to Array, it also provides a constructor that handles the integer arguments, but in a...
2 min read
We request you to subscribe our newsletter for upcoming updates.
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India