今天就学习课程吧!
今天就开通帐号,24,700 门业界名师课程任您挑!
Flat + map = flatMap
- [Instructor] The flatmap array method returns a new array by applying a callback function to each item of the array and then flattening it to one level. To put it in terms that you're familiar with, it first applies the array method map and then flat. The array method flatmap and calling map and then the array method flat on your array will return the same result. Just remember it's map then flat, despite the name of the array method. To be honest, I haven't yet encountered an opportunity to use flatmap in my code. But I still think it's worth learning should an opportunity arise. The syntax is one that we're very familiar with at this point, and it is identical to that of the array method map. The callback function accepts current value, index, and array. The current value is the only required parameter. Additionally, flatmap also accepts this ARG but as we've done with other array methods we're just going to…
随堂练习,边学边练
下载课堂讲义。学练结合,紧跟进度,轻松巩固知识。