I've come across JS code in which I see functions being declared in two different styles:
Method 1
function doSomething(){
alert('This is one way of declaring a function');
}
Method 2
doSomething = function() {
alert('And this is another way of declaring the same function');
}
So what is the difference between the two and is there a case scenario where it would make sense to follow one method over the other?
PS: Sorry if the title seems vague. I didn't know the technical term used to describe the way the above two functions are declared.
Aucun commentaire:
Enregistrer un commentaire