From the course: Learning ECMAScript 6+ (ES6+)
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Writing arrow functions - JavaScript Tutorial
From the course: Learning ECMAScript 6+ (ES6+)
Writing arrow functions
- [Instructor] Arrow functions have an abbreviated syntax for working with functions. We're dealing with a brand new token here. An equals sign and a greater than sign. And together that makes an arrow. So don't get that confused with comparison operators because it does something quite different. Let's create a function here called studentList. StudentList takes in some students and then it logs those students to the console. Now if I call studentList with an array, it's going to log those values. But arrow functions will allow me to use a slightly shorter syntax. So let's take a look at how I would refactor this function to use an arrow function. First I'd remove the function keyword. Then students is our arguments, right? So right after the arguments, I'm going to place that arrow. The way I think about it is it just points to whatever this function returns. Now this'll work as is with these curly braces. But…
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.