concept function parameter in category javascript

This is an excerpt from Manning's book Secrets of the JavaScript Ninja, Second Edition.
Most important, in JavaScript, functions are first-class objects, or first-class citizens as they’re often called. They coexist with, and can be treated like, any other JavaScript object. Just like the more mundane JavaScript data types, they can be referenced by variables, declared with literals, and even passed as function parameters. In this chapter, we’ll first take a look at the difference that this orientation to functions brings, and you’ll see how this can help us write more compact and easy-to-understand code, by allowing us to define functions right where we need them. We’ll also explore how to take advantage of functions as first-class objects in order to write better-performing functions. You’ll see various ways of defining functions, even including some new types, such as arrow functions, which will help you write more elegant code. Finally, we’ll look at the difference between function parameters and function arguments, with a special focus on ES6 additions, such as the rest and default parameters.
Listing 3.9. Tackling default parameters in ES6
function performAction(ninja, action = "skulking"){ #A return ninja + " " + action; } assert(performAction("Fuma") === "Fuma skulking", #B "The default value is used for Fuma"); #B #B assert(performAction("Yoshi") === "Yoshi skulking", #B "The default value is used for Yoshi"); #B #B assert(performAction("Hattori") === "Hattori skulking", #B "The default value is used for Hattori"); #B assert(performAction("Yagyu", "sneaking") === "Yagyu sneaking", #C "Yagyu can do whatever he pleases, even sneak!"); #C #A - In ES6, it’s possible to assign a value to a function parameter. #B - If the value isn’t passed in, the default value is used. #C - The passed value is used. !@%STYLE%@! {"css":"{\"css\": \"font-weight: bold;\"}","target":"[[{\"line\":0,\"ch\":2},{\"line\":0,\"ch\":53}]]"} !@%STYLE%@!