Why doesn't this arrow function work in IE 11?

后端 未结 4 1359
暖寄归人
暖寄归人 2020-11-22 00:12

Below piece of code does not work in IE 11, it throws a syntax error in the console

g.selectAll(\".mainBars\")
    .append(\"text\")
    .attr(\"x\", d =>         


        
4条回答
  •  一向
    一向 (楼主)
    2020-11-22 00:46

    In general, before arrow functions were arrow functions, they were regular JS functions. So with IE11 we just have to take a step back in time

    var fruits=["apple","banana","orange"];
    
    var modernResult=fruits.find(e => e.includes("nana"));
    console.log(modernResult);
    
    var IEresult=fruits.find(function(e){return e.includes("nana")});
    console.log(IEresult);
    
    

提交回复
热议问题