课程: JavaScript: Best Practices for Functions and Classes
今天就学习课程吧!
今天就开通帐号,24,700 门业界名师课程任您挑!
Use array destructuring - JavaScript教程
课程: JavaScript: Best Practices for Functions and Classes
Use array destructuring
- [Instructor] Array destructuring is similar to object destructuring. It lets me efficiently create named references to array elements instead of needing to reference using array index values. The files for this video include the distanceTo.js module, which expects an array containing five values. My code then assigns those values to variables, which I use in the code that follows. In these mathematical manipulations, referencing the values using labels for what they represent makes it a lot easier to follow what's going on. I can use the same eslint prefer-destructuring rule that I use for objects to specify how I want to use array destructuring in my code. By default, the rule applies to both objects and arrays, but I can configure it to apply to only one if I want. I'll start by adding that rule to my eslintrc file for this video. And that's prefer-destructuring and then the value's going to be an array. I'm going…
随堂练习,边学边练
下载课堂讲义。学练结合,紧跟进度,轻松巩固知识。