[Array.prototype中箭头功能的使用

问题描述 投票:-3回答:1

它在正常功能中工作正常。在箭头功能中,全局上下文本身被称为。 es6箭头功能中的等效功能是什么?无箭头功能

    Array.prototype.isEven=function(){
        return this.map(a=>a%2==0?true:false)
    }

具有箭头功能

    Array.prototype.isEven=()=>this.map(a=>a%2==0?true:false)
javascript prototype arrow-functions
1个回答
-2
投票

在箭头函数中,这将引用该元素将在触发该函数的事件上的引用。

© www.soinside.com 2019 - 2024. All rights reserved.