今天就学习课程吧!
今天就开通帐号,24,700 门业界名师课程任您挑!
Single values with reduce
- [Instructor] Have you ever encountered an array of values that needed to be added up and reduced to a single value or a grand total? This is where the array method, reduce, can be helpful to do just that. One of the most powerful array methods available is reduce. For me, this array method has been more difficult to grasp because of its syntax. I typically have to look it up for this array method because it does operate a little bit differently than the other array methods we've discussed thus far. So what exactly does reduce do? Reduce executes a reducer function against each item in the array, returning a single value. The value returned is the accumulated value. You'll often see this used with numbers, although it can be used with strings as well to determine counts and frequency. Where things get a little bit more tricky is with the syntax. Reduce uses a slightly different syntax than what we're used to seeing.…
随堂练习,边学边练
下载课堂讲义。学练结合,紧跟进度,轻松巩固知识。