js中箭頭函數(shù)和普通函數(shù)區(qū)別如下:
1、樣式不同,箭頭函數(shù)是 =>,普通函數(shù)是 function;
2、箭頭函數(shù)不能作為構(gòu)造函數(shù)使用,也就不能使用 new 關(guān)鍵字;
3、箭頭函數(shù)不綁定 arguments,可以考慮用剩余參數(shù)代替;
4、箭頭函數(shù)會捕獲其所在上下文的 this 值,作為自己的 this 值,定義的時候就確定了;
5、call、apply、bind 并不會影響 this 的指向;
6、箭頭函數(shù)沒有原型屬性;
7、箭頭函數(shù)不能當作 Generator 函數(shù),不能使用 yield 關(guān)鍵字;
推薦教程:js入門教程