Это видео недоступно.
Сожалеем об этом.
ONE tip to INSTANTLY up your JavaScript function game!
HTML-код
- Опубликовано: 4 окт 2018
- It's time to talk JavaScript, functions, destructuring, and a super simple and neat way to set up your parameters for maximum clarity and flexibility.
Time to get rid of that parameteritis, folks! 😂
This is the most underrated channel you should have at least 100+ K subs !
Well it's fairly new :) hopefully whoever joins in enjoys the videos, whether 1 person or 100k
Every time you bring something new in intro😁
Nice video.
We could take it further and use function argument destructuring with default values.
drawRectangle({ x = 0, y = 0, w = 100, h = 100, c = "#FFF", o = 1 } = {}) {
console.log(x, y, w, h, c, o)
}
As a bonus we get better intellisense suport and autocompletion.
😁 I don't know how you did it, but the intro is very funny! Thanks for the video. very helpful
I know all these things but _man_ these videos are fun to watch!
Passing to all my colleagues who are less proficient in JavaScript.
_And_ sooner or later I'll learn something new, no doubt. There's always something to learn.
Thank you for sharing. Yeah it is hard to go deep on the more advanced stuff without it being a lonnnng video. And I don't know yet what is most helpful, and also I have to make sure I can actually get the content out 👍😁
Ahhhhhh paul! Amazing. Thanks for the awesome tips! Love the videos and wacky antics. 😎🤓
Great video 👍 I'd love to see you do something on async await. E.g. how to rewrite promises, what are the implications of using it, if/when promises are the better option still?
✌️
awesome design pattern. video production is top-notch too.
Thanks Paul for making us smart everyday!
Hope I'm helping!
This is so cool I clicked on that bell icon for the first time ever. THANKS for this 😀
Thank YOU. I really appreciate it!
Yea, I did the same. I think this is the first JavaScript video that actually cracked me up.
Huge fan..... actually searched for you after watching your web dairy series on chrome dev channel...
Defaults in destructuring? Sweet!
Clever transitions with the two of you. Maybe a video on video production will be in order soon?
If you'd like I can share my process?
Your door looks of excellent quality.
It is oak. And yes I am a fan.
That is pretty cool
Thanks Paul for great tip! Subscribed with bell.
Thanks so much for the support and encouragement!
Oh, that's a cool tip! I'm going to start using this.
\o/
Doing this in Ruby for years! Also in JS its a nice little thing which makes the code more readable.
I first came across this kind of stuff in Flash :)
aww, a reply.. *Nerding out* Well I'm a "younger" programmer don't remember Flash, my first job was working with Angular 1.3 2014 :D More tipps like these would be nice.. I kinda am "stuck" with the problem "Okay I know I'm not a beginner programmer, but how can I evolve more ? Something like this makes you look "more professional" are there more tipps like this? I do know about DRY and WET and some basic design patterns..
Gotcha. Yes this is a big challenge, and honestly there are some things I've learned as I've gotten on in my career. Could make a video if it would help? They're not all 'coding' things though ;)
Sure, I'm all in on that! would appriciate it
Great tip. Take it one step further, and add it right into the declaration: drawRectangle({x =100, y = 100}) {}
Hehe sure! I guess I opt for whatever is consistent with the rest of the code, and whatever is the most obvious
Hi paul, we miss your live coding videos, can you please make a weekly series, we learn tons from you, thank you.
I mean, so far I'm doing these videos weekly! 😁👍
thank you
wicked tip, thanks!
Great tip !
Good one, thanks!
Other amazing video... you are the MAN!!!
isn't it possible to put all the defaults right into function declaration?
Yeah, but for clarity I decided to not. But absolutely you can
Could someone help me with JavaScripts for this game I play online plz I really need help?
I'm glad there's a way to do optional named parameters with defaults in JS, but I'd rather just have it built into the language syntax like Dart www.dartlang.org/guides/language/language-tour#optional-parameters
Do you mean the typing info? Because it looks like everything else you want is already there.
Don't get me wrong, I love the video and the content. My point is to inform how the same problem of parameter explosion or keeping an API non-breaking is solved in another language. I think Dart has tons of great language features that have eventually been included in JS. This approach is great but I feel like it is a non-obvious thing to do in javascript, especially for new developers. The downside I see is you have to remember and include that bit of runtime code in every place you want named parameters. I'm comparing it to Dart in which the method signature includes the fact that a parameter is optional and what the default value is. The compiler then does these checks and any runtime cost is not incurred. Here's the same interface in Dart (see it run or play with it here dartpad.dartlang.org/79fd25c6c771bdcd1ab8707cd29ed354)
class Shapes {
static void drawRectangle({x = 100, y = 100, w = 100, h = 100, c = '#FFF', o = 1}) {
print('$x $y $w $h $c $o');
}
}
void main() {
Shapes.drawRectangle(w: 777);
}
Briljant
I guess, instead of providing an empty object as the default value in the parameter, you can also do this, as a way to reduce all the modern JavaScript magic to a single line:
let {x = 0 ... } = options || {};
Yep there are a few ways to solve it. Normally when I do these snippets I go for maximum readability just because I want to make sure it hits home. But, yeah, absolutely it can be done like that 👍
@@aerotwist I prefer Paul's way because it is straight forward
Did you know JavaScript is a trademark owned by oracle?
More boring Paul please! 🙏❤️
In some ways he's always around 😁