Why cannot use lambda to define prototype function

前端 未结 3 536
一个人的身影
一个人的身影 2021-01-11 13:24

Can someone please explain why defining a prototype function with lambda expression doesn\'t work? I thought this must be asked before but couldn\'t find it.



        
3条回答
  •  太阳男子
    2021-01-11 14:13

    The Arrow function would resolve the context this belongs to the scope where the function was defined. I believe you have defined that function in window scope. So the this will point to window in your function.

    You can use normal anonymous function here. And we have to be careful while using arrow functions.

提交回复
热议问题