Home › Forums › JavaScript › Learning jQuery…Have a few questions › Re: Learning jQuery…Have a few questions
July 5, 2013 at 6:46 pm
#141693
pixelgrid
Participant
question #1
a and b are generally the same but the second one has to be defined before it gets called the first one can be called before declaring it
so
one();
function one(){
console.log(‘yes’);
}
//will log yes
two();
var two = function(){
console.log(‘no’);
}
typeerror two is not a function
in general the second case is used in objects when you want a method handler
Question #1 three you are declaring a function to the jquery prototype so you can use it with a jquery constructor
$(‘.my_selector’).my_custom_function();
question 2
the first one is a shorthand of the second one they are the same