12.21-12.25

# 12.21-12.25汇总 ## 1.cropper.js 裁剪图片 [github地址](https://github.com/fengyuanchen/cropperjs ) [教程帖](https://www.cnblogs.com/linxiyue/archive/2019/01/18/10288490.html) ## 2.ES6拓展运算符 扩展运算符( spread )是三个点(...)。它好比 rest 参数的逆运算,将一个数组转为用逗号分隔的参数序列。 ```js console.log(...[1, 2, 3]) // 1 2 3 console.log(1, ...[2, 3, 4], 5) // 1 2 3 4 5 [...document.querySelectorAll('div')] // [<div>, <div>, <div>] ``` 主要用于函数调用 ```js function push(array, ...items) { array.push(...items); } function add(x, y) { return x + y; } var numbers = [4, 38]; add(...numbers) // 42 ``` 代替数组的apply ```js // ES5 的写法 function f(x, y, z) { // ... } var args = [0, 1, 2]; f.apply(null, args); // ES6 的写法 function f(x, y, z) { // ... } var args = [0, 1, 2]; f(...args); ```