JavaScript Function Default Parameters

preview_player
Показать описание
New in the ES6 version of JavaScript are default function parameter values. This is something that has existed in other programming languages for quite a while but is new to JavaScript.
We can now create optional parameters for function arguments. We always had the ability to declare a long list of parameters in a function declaration and the function would run even when those parameters were not provided in the call to the function. The downside was that all the unprovided parameters had a value of undefined.
Now we can provide a default value for any parameter, which means that we truly have optional parameters for functions.

REMEMBER: always put your optional values at the end of your list. JavaScript won't know if you meant to skip over a value. The default values should be last and the required values should come first.

Рекомендации по теме
Комментарии
Автор

this was so well explained in such a short amount of time; thank you!

eilesec
Автор

Thanks for the explanation! This was the only video I found on JS Functional Deault Parameters for ES6!

hyfytale
Автор

As always, short and clear explanation - Thanks Steve

mohammedfakih
Автор

Thats a savage message you are passing as an argument😁

maxxinmaze
Автор

Thank you as always, following your tutorials are a pure delight. I have a question: why the "return true;" stattement is required in this lecture? I tried to remove that and it works without problem.

rotrose
Автор

Can we skip value for second parameter and pass value for third parameter ?

pradeepkumarreddykondreddy
Автор

How long to be good at javascript and get a entry level job without a degree? Is that really a thing?

nelsonjimenez