Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Point of putting a function in a var -JS [duplicate]

Tags:

javascript

Possible Duplicate:
Javascript: var functionName = function() {} vs function functionName() {}

What's the point of putting a function in a var or not?

var varFunc = function () {/*cool code*/};
function plainFunc() {
    /*cooler code?*/
}
like image 597
Devin Rhode Avatar asked Jan 24 '26 18:01

Devin Rhode


1 Answers

Assigning a function to a variable, aka anonymous functions, can be pretty useful once you know what they do.

Check this out - http://helephant.com/2008/08/23/javascript-anonymous-functions/

like image 150
David Ryder Avatar answered Jan 27 '26 08:01

David Ryder



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!