I read and followed several Backbone.js tutorials, and when it comes to model defaults, people seem to do this in one of two ways.
The first way - the default values ββare objects
The first way is that the default values ββare declared as an object, for example:
my_model = Backbone.Model.extend({ defaults: { title: 'Default Title' } });
This makes sense to me, I immediately know that by default this is an object and it works great.
The second way - default values ββ- is a function
The second way I've seen is that the default values ββare declared as a function, for example:
my_model = Backbone.Model.extend({ defaults: function() { return { title: 'Default Title' } } });
This function, obviously, completes the return of the object, and for me there is little point (if you do not want to somehow pass something to the function.
My question
My question is whether there is an advantage to using one over the other, assuming that you will not pass any parameters using the function. I feel that there may be a small overhead because the anonymous function will be called, but she would like a more informed opinion.
source share