From the course: Learning CoffeeScript
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Using aliases for "this" and other tidbits - CoffeeScript Tutorial
From the course: Learning CoffeeScript
Using aliases for "this" and other tidbits
Now cofeescript has a lot of other different ways that it tries to help you. So I'm going to talk about some of these in here. One of them is that it provides you with an alias for an argument called this. and it's pretty awesome. So let me explain about this a little bit. When a function is invoked, it gets two special parameters assigned to it. You may already know that functions come with an arguments parameter. That argument allows you to list all the items that were passed to the function, and it could be pretty useful. Well, in addition to that, every function also gets a this argument, and it's supposed to let you access the current object. Normally, you would expect This to refer to the function that you're using. But in a lot of instances, it returns the wrong thing. So, it really makes more sense if I show it to you. Let go ahead and create a new function here. We'll call it fill and it'll take item. And we'll use a CoffeeScript arrow to execute this function. I'm going to…
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)
-