Suppose I have a function that bypasses an array ...
flatten([a, b, c, d, [e, f, g, [h, i, j, k], l], m, n, o, p]) >> [a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p]
Flatten will scan the code and for each array it encounters, it will recursively enter this array and return values, so you have a flat array.
This works until we have an array, for example:
a = []; a[0] = a;
This obviously creates infinite recursion:
Array[1] 0: Array[1] 0: Array[1] 0: Array[1] 0: Array[1] 0: Array[1] 0: Array[1] ...
How can I detect this behavior without modifying the array so the function can handle it?