If I have a function that creates an object, do some stuff and than returns it. If it's true that objects are passed by reference, does this mean that the function that creates the object (or the function's scope chain) will not be available for garbage collection?
Example code:
function convertArrayToObj(array){
var newObj = {};
array.forEach(function(item, index){
newObj[index] = item;
});
return newObj;
}
I hope I made my doubt clear
Aucun commentaire:
Enregistrer un commentaire