Is there a noticeable delay when passing around an object within the same scope? Let's explore Option 1 and Option 2. In Option 1, we work directly with the object, while in Option 2 we follow better encapsulation practices. However, if we were to still pass the object within the same scope, would it be slower (considering large arrays of objects with numerous properties)?
var sampleObject = {id:2, objString = 'something'};
Option 1:
function addPropToObject(){
sampleObject.someNewProp = 'lalala'
}
Option 2:
function addPropToObject(obj){
obj.someNewProp = 'lalala'
}
addPropToObject(sampleObject);
The presence of the AngularJs tag is included in case the function was:
$scope.adPropToObject = function(){....
In my opinion, it shouldn't make any difference. Feel free to suggest a new title if you have one in mind.