Reputation: 55
I look into the jQuery source v.1.8.1 and search the jQuery.fx.speeds and its value is
jQuery.fx.speeds = {
slow: 600,
fast: 200,
// Default speed
_default: 400 };
Why did the jQuery developers use "_defaults" instead of "defaults"??
jQuery.fx.speeds = {
slow: 600,
fast: 200,
// Default speed
// Default without underscore prefix in it
default: 400 };
What is the benefits having a property with a prefixed underscore?? What the heck does the underscore stands for??
Example ..
var obj = {};
obj.property = "property value";
obj._property = "property value with _";
alert( obj._property );
alert( obj.property );
When does the obj._property is more appropriate use than obj.property??
Thanks...
Upvotes: 0
Views: 116
Reputation: 4264
The prefixed underscore makes it unlikely that someone using the library would use a variable with the same name.
Upvotes: 0
Reputation: 48761
The leading underscore usually used to avoid naming conflicts.
It could be that jQuery allows you to define your own named durations, or had planned on the possibility, so this would handle the case where someone wants to use the name "default"
.
So it's just a convention used. The underscore itself doesn't change the nature or behavior of the property.
Upvotes: 1