One very common operation in programming is to iterate through an Array's contents, apply a function to each item, and create a new array containing the results. For example, let's say you wanted to loop through an array of stock objects and select only the name for display on screen. In this lesson we will demonstrate how to use the Array's map
method to easily perform this operation with less code than a loop would require.
Hi, I have a question regarding the symbols object. After the function has run has the values in this object been replaced and only contains the symbols, or does it still contain price and volume?
Only symbols are in the array.
A very bad example for beginners. However, master doesn't look anything useful. Awful example, can't imagine why and for what i pay the money. W3Schools explains better.
Hi, Could you please explain why: var symbols = getStockSymbols([ ..........]) var is assigned to an array and on line #1 it is function with the same name?
I think you were just tired when watching this and probably figured it out by yourself :) however on the first line you define the function, which accepts an array of stock objects, and finally, you just invoke that function, passing the whole array manually (pretend you are fetching some data from whatever api), and then storing a reference to the symbols array returned from the function in a variable called "symbols" (the "var symbols..." thing you mentioned ).