Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialOzgur Canibeyaz
3,126 Pointsjavascript functions
Why use 2 different approaches when defining functions.
var debug = function() {}
and function myFunc() {}
and how about the difference between void functions and functions that return a value ?
3 Answers
James Barnett
39,199 PointsThat's called an anonymous function, it works roughly the same way as a traditional function. The same goes for return values, in JavaScript functions can either return a value or not.
No need to worry if you are wondering about some of the finer points of functions in JavaScript, the JavaScript Foundations course has a whole badge devoted to functions in particular it has a video devoted to working with anonymous functions.
If you are doing the Front-end Web Developement track, the JavaScript Foundations course will be your next course.
Andrew Shook
31,709 PointsTake a look at this stackoverflow.
Ozgur Canibeyaz
3,126 Pointsthanks a lot