I'm new in ReactNative / Javascript. One weird thing that I notice is that if I have an array from parameter (ex: [1, 0, 1, -1]
) and assign it to another variable and console.log
it, I will get like an infinite array content.
myFunc = (array) => {
console.log("ARRAY:");
console.log(array);
var result = array;
console.log("RESULT:");
console.log(result);
}
Resulting console log in iOS:
ARRAY:
[ 1, 0, 1, -1 ]
RESULT:
[ 1,
0,
1,
-1,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
... 100 more rows
,
[] ]
Why is this happening? And how to correctly assigning array contents from one variable to another?
Note that this only happens if the data is gotten from parameter. If I casually have var array = [1, 0, 1, -1]
and assign it to another variable, there's no problem with that.