![]() |
The with() method in JavaScript Array returns a new array with the element at the given index replaced with the given value. Syntax:
Parameters:
Example 1: Consider a JavaScript array with 5 elements and replace the value present at Index position – 4 with 100.
Output: Existing Array: [60, 78, 90, 34, 67] Example 2: Let’s apply map() function to this function and replace the element present at index – 4 with 100 multiplied by 2.
Output: Existing Array: [60, 78, 90, 34, 67] |
Reffered: https://www.geeksforgeeks.org
JavaScript |
Type: | Geek |
Category: | Coding |
Sub Category: | Tutorial |
Uploaded by: | Admin |
Views: | 13 |