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.
Working with splats - CoffeeScript Tutorial
From the course: Learning CoffeeScript
Working with splats
Splats is one of those really cool and unique features of CoffeeScript. They allow you to feed an unknown amount of elements into a function without specifying the quantity. This is kind of similar to the way that the argument array works in JavaScript, but it's a little more flexible. So, the only way to understand them is to see them in action. Let's go ahead and create a new array. We'll call this one info. And we'll just set this array to some different elements. This is going to have my name and then just a few websites. Okay, now I'm going to create a function and I'm going to feed some of these parameters into the function. So, the function's going to be called fillOut. And, just like any other function, it's going to have an equal sign. And then I'm going to pass it along some parameters. Here's where the splats come in. I know that I want the first element of that array that I I'm feeding in here to be in the name. And then I want a second group of element, but I'm not sure…
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)
-