Join Ray Villalobos for an in-depth discussion in this video Adding basic functions, part of Learning CoffeeScript.
…It's almost impossible to talk about CoffeeScript without doing…functions, and you've already seen me use a few examples.…Let's go ahead and spend some time focusing on them in this movie.…Now, you probably already know that the function…keyword is gone in CoffeeScript, along with parentheses.…You don't need to use either of those.…You can create a function by doing something like this, creating the name…and then using the equals sign plus the dash and the greater than sign.…And then, you can execute any statement you want.…And that creates the function and also…creates the variable for the function automatically.…
So it's name-spacing the function for you.…This function's not executing, because we haven't invoked it.…You can invoke the function just by calling it by name.…When you do that, though, if it doesn't…have any parameters, you are going to need the parentheses.…So if you say myFunction, notice that it will say Hello here now in the console.…If you try to call it without parentheses, that's not going to work.…
- What is CoffeeScript?
- Setting up a project with Gulp.js
- Adding CoffeeScript to your workflow
- Dealing with array ranges
- Working with conditional statements
- Using loops
- Working with splats