Skip to main content

Default parameters


Default parameters allow you to set default values for function parameters if the function is called without arguments, or if the parameter is explicitly passed the value undefined.


In JavaScript, function parametersβš™οΈ that are not passed values when called are defaulted to undefined. However, in some cases it may be useful to set a different default value. This is where the default options are intended.



Live Editor
SyntaxError: Unexpected token (1:8)
1 : return ()

Passing other "false" values#


If any value other than undefined is passed to the formal parameter during the call, including one of the" false "values such as false ❎, 0, " ", '', null,NaN, then in this case the default value will not be assigned to the parameter. In this case, you need to write the code yourself that will catch these "false values".


Now you are on a stripped-down version of the site, after subscribing to Patreon, you will get full access to the training course, as well as access to our server's private channels in Discord.

Download our mobile application or get tested in our JavaScript telegram bot, and also subscribe to our news.

Become a Patron!

Sumerian school


  1. MDN web docs

Contributors ✨#

Thanks goes to these wonderful people (emoji key):

Philipp Dvinyaninov


Dmitriy Vasilev



πŸ› 🎨 πŸ–‹


πŸ–‹ πŸ› 🎨

Become a Patron!