Use the map to create a new array wording

For example, the original array returned ten attributes, you want two, but also and attribute names are not the same as before, you can write similar to the following wording:

          const users = result.map(item => ({
            name: item.login,
            avatarUrl: item.avatar_url,
            url: item.html_url
          }));

Wherein ({}) is written, similar to the wording return {}

Guess you like

Origin www.cnblogs.com/llcdbk/p/12229347.html
Recommended