课程: Mastering Web Developer Interview Code

免费学习该课程!

今天就开通帐号,24,700 门业界名师课程任您挑!

Show me how to use the map function

Show me how to use the map function

- [Narrator] Moving through lists of elements is a fundamental task in just about any programming job. Now JavaScript provides a lot of methods for doing it and one of the lesser used yet, very popular methods is called map. So let's take a look at how it works and more importantly, what makes it unique. There's a few Ways to go through a list and the oldest and probably the one that is most familiar to people is the forest statement. Next in that in order for popularity is the forEach. And it always seems a good idea to use forEach when going through array elements because its name is pretty expressive, right? For each one of these things, then do the following. Now the last option is what we're talking about here though and it is the map statement. The main advantage of map over some of these other methods is that it's designed so that it avoids transforming the original array where forEach is often used for instances…

内容