1、箭頭函式是匿名函式,不能作為建構函式,不能使用new
2、箭頭函式不能繫結arguments,取而代之用rest引數…解決let
funconstructor=(
)=>
let fc=
newfunconstructor()
;//uncaught typeerror:funconstructor is not a constructor at :1:10
3、箭頭函式沒有原型屬性function
argu
(a)argu(1
,2,3
,4,5
)//arguments(5) [1, 2, 3, 4, 5, callee: ƒ, symbol(symbol.iterator): ƒ]
letarrowagru=(
...a)
=>
arrowagru(3
,83,8887,99
)//(4) [3, 83, 8887, 99]
4、箭頭函式的this永遠指向其上下文的this,沒有辦法改變其指向,普通函式的this指向呼叫它的物件let
proa=(
)=>
function
prob()
console.
log(proa.prototype)
; console.
log(prob.prototype)
;// undefined
//
5、箭頭函式不繫結this,會捕獲其所在的上下文的this值,作為自己的this值
let obj=},
c:function()
}}obj.b(
);obj.c(
);
7、箭頭函式不能當做generator函式,不能使用yield關鍵字let obj2=
, c:
function
(n);
return f.
call
(m,n);}
}console.
log(obj2.b(
1));
//11
console.
log(obj2.c(
1));
//11
箭頭函式與普通函式區別
1 箭頭函式是匿名函式,不能作為建構函式,不能使用new 2 箭頭函式不繫結arguments,取而代之用rest引數 解決 3 this的作用域不同,箭頭函式不繫結this,會捕獲函式定義的上下文中的this值,作為自己的this值,且一直不變 4 箭頭函式沒有原型物件 5 箭頭函式不能當作gen...
箭頭函式與普通函式的區別
箭頭函式和普通函式的區別 首先就是 箭頭函式作為匿名函式,是不能作為建構函式的 再者就是更重要的一點 箭頭函式的特點就是不繫結this和arguments 舉個例子 settimeout function 3000 以上是乙個延時定時器中的普通function 我們都知道定時器中會改變this的指向...
箭頭函式與普通函式的區別
箭頭函式 let fun 普通函式 function fun 箭頭函式相當於匿名函式,並且簡化了函式定義。箭頭函式有兩種格式,一種只包含乙個表示式,連和return都省略掉了。還有一種可以包含多條語句,這時候就不能省略和return。箭頭函式是匿名函式,不能作為建構函式,不能使用newlet fun...