From the course: Learning the JavaScript Language

Unlock the full course today

Join today to access over 24,400 courses taught by industry experts.

Writing shorter functions with arrows

Writing shorter functions with arrows - JavaScript Tutorial

From the course: Learning the JavaScript Language

Writing shorter functions with arrows

- [Instructor] Writing functions doesn't take a ton of keystrokes, but in this video we'll explore arrow functions, which are part of ECMAScript 2015 that allow functions to be defined with fewer keystrokes. JavaScript is very function-oriented. Indeed, you can use it in a formally functional way, which pretty much means everything would be done via functions. As a result, being able to define a function with less typing is pretty handy. Let's look at this speech function that prints a few animal noises. This is written as a function expression assigned to a constant called speak. This is just like what we've seen previously. We have our function keyword. It's unnamed because we're assigning it to this variable and then we have our curly braces with the things we want it to do. With an arrow function, we can save even having to type that word function. We just leave it off. But in order for this to be recognized as a…

Contents