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 trial

JavaScript Introduction to Programming Functions Functions

javascript 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
James Barnett
39,199 Points

That'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.

thanks a lot