You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
repeat back to array and endlessly loop through this
if you go into your command line, I'm using chrome, and do something like:
arr = [];
arr[0] = arr;
You can endlessly open up each consecutive arr's first index.
arr[0] = arr
arr[0][0] = arr
arr[0][0][0] = arr
... and so forth .
FIX
When recursively looping through an object's keys/array, make sure the value associated with the key does not refer to the parent. If it is the parent, don't proceed with the recursion; just move on.
Also, you don't want extreme cases where something like this happens:
var par = { child:{ child2:[ 1, 2, "object", actualObject, par] } }
This case there will be an endless loop emerging from child2 because it refers to a higher path.
general code fix:
/// outer scope
var objectsRegistered = []; // let objects be ran through ONLY once.
// lower scope
if( typeof value === typeof object ){
if ( objectsRegistered.indexOf( value ) > -1 ){
return;
}
objectsRegistered.push( value );
// do further processing here
}
Been using bind in a private node project, and this causes a pretty serious bail:
The text was updated successfully, but these errors were encountered: