How to clean up code by using default function parameters #shorts

preview_player
Показать описание
When writing a javascript function, it's often useful to have parameters be defaulted to a certain value instead of letting them default to undefined.

#shorts

------------

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

Mark my words, with the condition that this man makes videos consistently, this channel would reach 1 million. Such a concise and digestible way of teaching. Thank you, love from Pakistan.

haiderimam
Автор

How can you do this with multiple default parameters? If I just want to update of them?

const f = (a, b=2, c=3) …..

f(1, c=4)

How would you do this?

WhereRickyTanAt
Автор

if age = 0, then age = 10 with that !age constructon there. To avoid falsy use ??
age = age ?? DEFAULT_AGE

bvaroni
Автор

not if you're using an array as a default parameter though cause different function calls will share it.

wumbl
Автор

how do you clean code by chaging 4 to 5 variables to one single function ?

lucanthony
join shbcf.ru