Javascript

JavaScript Fundamentals -- Functions in JavaScript

PRO
Outline

Functions are an important part of JavaScript. In this section, we'll learn how to write and use them. In this section, we'll cover:

  • Named Functions
  • Anonymous Functions
  • Arrow Functions
  • Default Parameters
  • Named Parameters
  • Rest Parameters

It's also important to know the difference between an argument and a parameter. An argument is the value you pass into a function. A parameter is the name you assign that value inside the function. Here's an example:

function sayHello(name) {
  console.log('Hello ',  name);
}

sayHello('Preston');

In this example, the name variable in the sayHello function is the parameter. When the function is called at the end of the example, 'Preston' is the argument. You may hear people use these interchangeably, and that's mostly okay, but they are different.

You can follow along with this section by forking this StackBlitz project.

 

I finished! On to the next chapter