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

Working with splats - CoffeeScript Tutorial

From the course: Learning CoffeeScript

Start my 1-month free trial

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…

Contents