标签:turn 调用 double pre func ble class div 箭头函数
1.缩减代码
function double(number){ return number*2; } console.log(double(20)) const double2 = number => number*2; console.log(double2(15))
2.改变this指向 (this 始终指向调用它的对象 ES6中箭头函数的this指向函数上边的对象)
let team = { tName:"man", people:[‘jack‘,‘jerry‘], order:function(){ return this.people.map(people => { return `${people}隶属于${this.tName}小组`; }); } } console.log(team.order()); //["jack隶属于man小组", "jerry隶属于man小组"]
标签:turn 调用 double pre func ble class div 箭头函数
原文地址:https://www.cnblogs.com/webmc/p/11623278.html