In javascript we can change properties of constant object. So if I have some factory in AngularJs defined as below
myApp.factory('sampleFactor', function() {
var sampleFactoryVar = {
setFoobar: function(foo){
//perform some operations
return foo;
},
getFoobar:function(){
//perform some operations
}
};
return sampleFactoryVar;
});
In this factory if I will be declaring sampleFactoryVar as const will it make any significant impact on performance ?
Please consider sampleFactoryVar is holding lots of properties.
No, it won't have any effect at all. You could in fact just omit the variable declaration and just return the object literal directly. However the factory is only called once, so performance hardly matters here anyway.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With