map () method creates🏗️ a new с array with the result of calling the specified function⚙️ for each element of the array.
map method calls the passed
callback function once for each element, in the order of their occurrence, and constructs a new array from the results of its call. The
callback function is called only for array indices that have assigned values, including
undefined. It is not called for missing array elements (that is, for indices that were never specified, deleted, or never assigned a value).
callback is called with three arguments:
- the value of the element,
- element index
- and the array through which the passage is carried out.
thisArg parameter was passed to the
map method, it will be used as the
this value when
callback is called. Otherwise, the
this value will be
undefined. Ultimately, the value of
this as seen from the
callback function is determined according to the usual rules for defining
this as seen from a function.
map method does not modify the array for which it was called (although the function⚙️ can do that!).
The range of elements processed by the
map method is set before the first call to the
callback function. Items added to the array after the start of the
map method will not be visited by the
callback function. If the existing elements of the array are modified by the
callback function, their values passed to the function will be the values at the time when the
map method visits them. Deleted items will not be visited.
Thanks goes to these wonderful people (emoji key):
🐛 🎨 🖋
🖋 🐛 🎨