e v m

Functions

December 09, 2019
0 Comments

Functions are one of the building blocks of programming, they are the worker bees that take away complexity from the main execution context. In Javascript, they are scope creators. What is in the function is only to the function and the functions defined inside that function.

1
function username(firstName, lastName) {
2
return `${firstName} ${lastName}`;
3
}

Let’s take a look at this function. First we define a name of our function, username, we need this name so we can call it later. It has to be unique for the same scope.

Inside ( ) we have firsName and lastName parameters. These are telling our function, that our function will need these values to run. Afterwards we return string template literal.

  • Dictionary: Check out the string literal and string literal template section at the Dictionary

Emil Martinov

Written by Emil Martinov who lives Rotterdam || Istanbul and loves everything js. He tweets mostly about js.