Object doesn't support property or method 'fill'

后端 未结 7 795
谎友^
谎友^ 2021-01-04 08:07

I cannot find same problem online. IE 11 gives error \"Object doesn\'t support property or method fill\".

var arr = new Array(5);
arr.fill(false         


        
7条回答
  •  再見小時候
    2021-01-04 09:05

    You could use Array.apply for getting an array with the wanted length and then map the value to it.

    var a = Array.apply(null, { length: 5 }).map(function () { return false; });
    console.log(a);

提交回复
热议问题