Parameters

Learn about parameters and their types.

We'll cover the following...

We covered functions previously, but now it’s time to dig a bit deeper and look at some more advanced topics specific to JavaScript.

Named parameters

When a function has quite a few parameters, it can be difficult to remember what order to write the arguments in when we call the function. For example, consider this function that returns a styled <div> element:

Press + to interact
function heading(text, color, size, bgcolor) {
return `<h1 style='color:${color};background-color:${bgcolor};font-size:${size}>${text}</h1>`
}

This uses positional parameters, which means that when the function is called, the position the ...