I'm a full stack Typescript developer specialising in Angular and Node. I love reactive programming with RxJS, utilising the less-used web APIs and I'm passionate about polymorphic full stack TS.
could you ever shoot yourself in the foot with this call, or does it protect me from my own shenanigans?
Yep you can shoot yourself in the foot - if for some reason your array contains circular references .flat(Infinity) will cause a stack overflow.
demo:
a=[1,2,3]b=[4,5,6]a.push(b)b.push(a)a.flat(Infinity)// VM185:9 Uncaught RangeError: Maximum call stack size exceeded// at Array.flat (<anonymous>)// at <anonymous>:9:3
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Yep you can shoot yourself in the foot - if for some reason your array contains circular references
.flat(Infinity)
will cause a stack overflow.demo: