Это видео недоступно.
Сожалеем об этом.

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! 😂

Комментарии • 53

  • @ristekostadinov2820
    @ristekostadinov2820 5 лет назад

    This is the most underrated channel you should have at least 100+ K subs !

    • @aerotwist
      @aerotwist  5 лет назад +1

      Well it's fairly new :) hopefully whoever joins in enjoys the videos, whether 1 person or 100k

  • @harshkumar8025
    @harshkumar8025 5 лет назад +8

    Every time you bring something new in intro😁

  • @lukaspapay
    @lukaspapay 4 года назад +1

    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.

  • @michongoma7598
    @michongoma7598 5 лет назад +1

    😁 I don't know how you did it, but the intro is very funny! Thanks for the video. very helpful

  • @MaxArt2501
    @MaxArt2501 5 лет назад

    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.

    • @aerotwist
      @aerotwist  5 лет назад +1

      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 👍😁

  • @RabbitWerksJavaScript
    @RabbitWerksJavaScript 5 лет назад

    Ahhhhhh paul! Amazing. Thanks for the awesome tips! Love the videos and wacky antics. 😎🤓

  • @nut315
    @nut315 5 лет назад +3

    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?
    ✌️

  • @Chris-bt4hx
    @Chris-bt4hx 5 лет назад

    awesome design pattern. video production is top-notch too.

  • @mmahgoub
    @mmahgoub 5 лет назад

    Thanks Paul for making us smart everyday!

  • @maximerossignol582
    @maximerossignol582 5 лет назад +1

    This is so cool I clicked on that bell icon for the first time ever. THANKS for this 😀

    • @aerotwist
      @aerotwist  5 лет назад

      Thank YOU. I really appreciate it!

    • @PaulMcCannWebBuilder
      @PaulMcCannWebBuilder 5 лет назад

      Yea, I did the same. I think this is the first JavaScript video that actually cracked me up.

  • @SAS-qq5ce
    @SAS-qq5ce 5 лет назад

    Huge fan..... actually searched for you after watching your web dairy series on chrome dev channel...

  • @analemma.inflection
    @analemma.inflection 5 лет назад

    Defaults in destructuring? Sweet!

  • @alexgrant6958
    @alexgrant6958 5 лет назад

    Clever transitions with the two of you. Maybe a video on video production will be in order soon?

    • @aerotwist
      @aerotwist  5 лет назад +5

      If you'd like I can share my process?

  • @redders6600
    @redders6600 5 лет назад

    Your door looks of excellent quality.

    • @aerotwist
      @aerotwist  5 лет назад

      It is oak. And yes I am a fan.

  • @rhodium2010
    @rhodium2010 5 лет назад

    That is pretty cool

  • @steadyannie3467
    @steadyannie3467 5 лет назад

    Thanks Paul for great tip! Subscribed with bell.

    • @aerotwist
      @aerotwist  5 лет назад

      Thanks so much for the support and encouragement!

  • @greentea5593
    @greentea5593 5 лет назад

    Oh, that's a cool tip! I'm going to start using this.

  • @NeoChromer
    @NeoChromer 5 лет назад

    Doing this in Ruby for years! Also in JS its a nice little thing which makes the code more readable.

    • @aerotwist
      @aerotwist  5 лет назад

      I first came across this kind of stuff in Flash :)

    • @NeoChromer
      @NeoChromer 5 лет назад

      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..

    • @aerotwist
      @aerotwist  5 лет назад +2

      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 ;)

    • @NeoChromer
      @NeoChromer 5 лет назад

      Sure, I'm all in on that! would appriciate it

  • @bartlewis
    @bartlewis 5 лет назад

    Great tip. Take it one step further, and add it right into the declaration: drawRectangle({x =100, y = 100}) {}

    • @aerotwist
      @aerotwist  5 лет назад

      Hehe sure! I guess I opt for whatever is consistent with the rest of the code, and whatever is the most obvious

  • @mohamadtajjiou7508
    @mohamadtajjiou7508 5 лет назад

    Hi paul, we miss your live coding videos, can you please make a weekly series, we learn tons from you, thank you.

  • @EvilPlank
    @EvilPlank 5 лет назад

    wicked tip, thanks!

  • @DenisTRUFFAUT
    @DenisTRUFFAUT 5 лет назад

    Great tip !

  • @zekezekeish
    @zekezekeish 5 лет назад

    Good one, thanks!

  • @mauroreisvieira
    @mauroreisvieira 5 лет назад

    Other amazing video... you are the MAN!!!

  • @qwiglydee
    @qwiglydee 5 лет назад +1

    isn't it possible to put all the defaults right into function declaration?

    • @aerotwist
      @aerotwist  5 лет назад

      Yeah, but for clarity I decided to not. But absolutely you can

  • @acethomas5774
    @acethomas5774 3 года назад

    Could someone help me with JavaScripts for this game I play online plz I really need help?

  • @RobBecker
    @RobBecker 5 лет назад

    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

    • @aerotwist
      @aerotwist  5 лет назад

      Do you mean the typing info? Because it looks like everything else you want is already there.

    • @RobBecker
      @RobBecker 5 лет назад

      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);
      }

  • @glashio
    @glashio 5 лет назад

    Briljant

  •  5 лет назад

    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 || {};

    • @aerotwist
      @aerotwist  5 лет назад +1

      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 👍

    • @reactarabic5767
      @reactarabic5767 5 лет назад

      @@aerotwist I prefer Paul's way because it is straight forward

  • @AndrewBone
    @AndrewBone 5 лет назад

    Did you know JavaScript is a trademark owned by oracle?

  • @JonAthan-ln2wn
    @JonAthan-ln2wn 5 лет назад

    More boring Paul please! 🙏❤️

    • @aerotwist
      @aerotwist  5 лет назад +1

      In some ways he's always around 😁