From the course: Learning CoffeeScript
Unlock the full course today
Join today to access over 22,700 courses taught by industry experts or purchase this course individually.
Adding basic functions - CoffeeScript Tutorial
From the course: Learning CoffeeScript
Adding basic functions
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…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
(Locked)
Basic CoffeeScript syntax7m 15s
-
(Locked)
Using realistic assets5m 24s
-
(Locked)
Understanding variables10m 11s
-
(Locked)
Dealing with array ranges4m
-
(Locked)
Working with conditional statements5m 2s
-
(Locked)
Using loops and comprehensions4m 14s
-
(Locked)
Adding basic functions2m 57s
-
(Locked)
Working with splats3m 28s
-
(Locked)
Using the switch statement2m 51s
-
(Locked)
Using aliases for "this" and other tidbits3m 57s
-
(Locked)
-