Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Object doesn't support property or method 'fill'

Tags:

javascript

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);

Is there any convenient way to to fill an array instead of using a for loop? Thanks.

like image 711
6324 Avatar asked Jun 09 '16 14:06

6324


3 Answers

I face the same issue, not to add anything.

Just open polyfills.ts file and un-comment following lines:

/** IE9, IE10 and IE11 requires all of the following polyfills. **/
import 'core-js/es6/symbol';
import 'core-js/es6/object';
import 'core-js/es6/function';
import 'core-js/es6/parse-int';
import 'core-js/es6/parse-float';
import 'core-js/es6/number';
import 'core-js/es6/math';
import 'core-js/es6/string';
import 'core-js/es6/date';
import 'core-js/es6/array';
import 'core-js/es6/regexp';
import 'core-js/es6/map';
import 'core-js/es6/weak-map';
import 'core-js/es6/set';

Every thing will start working.

like image 160
Ali Adravi Avatar answered Oct 20 '22 18:10

Ali Adravi


Install the trivial polyfill and continue using .fill(…).

like image 13
Bergi Avatar answered Oct 20 '22 16:10

Bergi


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);
like image 1
Nina Scholz Avatar answered Oct 20 '22 16:10

Nina Scholz