forEach() method is used to loop through each element of an array .
The forEach() method takes a callback function as an argument.
The callback function is invoked for each element of the array or object.
map() method is used to loop through each element of an array .
The map() method takes a callback function as an argument.
The callback function is invoked for each element of the array or object.
Both map() method and forEach() method are similar but it returns a new array.
0 Comments:
Post a Comment