Almog Hazan
Almog Hazan

Reputation: 147

IE array.flat() Object doesn't support property or method 'flat'

When accessing my website from google chrome everything works fine(also on mobile). but when trying to access from edge \ mobile normal browser(not google chrome) i get

TypeError: Object doesn't support property or method 'flat'

trying to access a function .flat of array.

turns out that it dosent exist on the proto at all. what can i do with it? the childs array is defined as

`let childs = [];`

(using react for front end)enter image description here

Upvotes: 10

Views: 11125

Answers (1)

wang
wang

Reputation: 1780

IE does not support Array.prototype.flat(). you can use reduce and concat as a workaround:

childs = childs.reduce((acc, val) => acc.concat(val), [])

Upvotes: 26

Related Questions