Reputation: 33
Could anybody give me an explanation of the underscore in a jQuery plugin function? I have no idea of what "_" means. Example code below:
$.fn.bgStretch=function(o){
this.each(function(){
var th=$(this),
data=th.data('bgStretch'),
_={
align:'leftTop',
altCSS:{},
css:{
leftTop:{
left:0,
right:'auto',
top:0,
bottom:'auto'
},
rightTop:{
left:'auto',
right:0,
top:0,
bottom:'auto'
},
leftBottom:{
left:0,
right:'auto',
top:'auto',
bottom:0
},
rightBottom:{
left:'auto',
right:0,
top:'auto',
bottom:0
}
},
preFu:function(){
_.img
.load(function(){
_.checkWidthFu()
_.img
Upvotes: 3
Views: 2062
Reputation: 54022
Just a variable
A JavaScript identifier must start with a letter, underscore (_), or dollar sign ($); subsequent characters can also be digits (0-9). Because JavaScript is case sensitive, letters include the characters "A" through "Z" (uppercase) and the characters "a" through "z" (lowercase).
Upvotes: 0
Reputation: 1080
Just as lanzz commented. This is a variable.
Look at how the varaiables are declared:
var th=$(this),
data=th.data('bgStretch'),
_={..}
Another way to it is:
var th=$(this);
var data = th.data('bgStretch');
var _ ={...};
It might as well have been called _someVar
.
Upvotes: 3