Also works with functions as a default params like a charm function callSomething(hey = heyNinja()) { return hey; } function heyNinja() { return 'Hey Ninja'; } callSomething(); //Hey Ninja Peace.
I was asking myself the same question. You can pass "undefined" for the arguments you want the default value for, and a specific value if not. See developer.mozilla.org/en/docs/Web/JavaScript/Reference/Functions/Default_parameters
Short and precise. quite easy to understand
Very cool! Net Ninja has the best tutorials on the web!
Hello `undefined`, I'm Dad!
btw, really good tutorial, to the point and cristal clear!
Glad you liked it! :)
Great Tutorial, love your series, many thanks
Thanks :)
You are the best man! Easy and simple, nice work!
Thanks :)
Nice and neat explaination. Keep it up mate
I love how ES6 is behaving more and more like Python
Thank you. This channel is the best.
Wow, thanks Kev!
Very nice breakdown👍
you are the best on youtube, thank you
very concise and helpful, thanks!
Thanks guy! Simple and objective
BTW, It's not 40, lol, I like your tutorials, thx a lot!
And the belt is manly
Realy good quality tuts!
+Francis DC Cheers bro, glad you like :)
Thank you!
on point
thanks netninja
Also works with functions as a default params like a charm
function callSomething(hey = heyNinja()) {
return hey;
}
function heyNinja() {
return 'Hey Ninja';
}
callSomething(); //Hey Ninja
Peace.
Tnx
nice really helped thanks :)
thanks very usefull
Awesome!
Great tutorial. how could this be used in a constructor prototype function?
I can tell you like Street Fighter.
Good tuts but you missed off how you pass in say just the belt colour?
I was asking myself the same question. You can pass "undefined" for the arguments you want the default value for, and a specific value if not. See developer.mozilla.org/en/docs/Web/JavaScript/Reference/Functions/Default_parameters
Can you set default objects as parameter and override them? I am used to doing this in PHP. Seeing that ES6 now has default parameters is exciting.
but how can you skip the middle parameter ??? logNinja("shaun", ,40); so it can insert default "red"???
you send it as keyword arguments
Who dislikes this?
Great tutorial, however it can be shorter. There's no need to explain further after 2.00 mark
You're aware that there is a next button that you could always press, right?