今天举个简单的例子:
项目中遇到已知是纯number类型的数组,需要取该数组的极值,
ES5:let Array = [-0.1,0,19,23,66.1,1,5,7,99,0,23,1,55],tempMax = Math.max.apply(Math, Array)tempMin = Math.min.apply(Math, Array)// 99// -0.1ES6:let Array = [-0.1,0,19,23,66.1,1,5,7,99,0,23,1,55],tempMax = Math.max(... Array)tempMin = Math.min(... Array)// 99//-0.1^_^