Higher Order Functions: A JavaScript Strong Point

แชร์
ฝัง
  • เผยแพร่เมื่อ 15 ต.ค. 2024
  • How does the concept of higher order functions relate to first class functions? What is a higher order function? In this tutorial we answer these questions and show an example of a higher order function using the sort method to alphabetically sort the elements in an array.
    Would you like to help keep this channel going?
    / allthingsjavascript
    For a complete list of all our tutorials:
    www.allthingsja...
    Access to EVERY course (get 2 months free): www.skillshare...
    Courses offered on Udemy at a discount (access from my site): allthingsjavasc...
    To view a tutorial on the ES5 array methods: • Getting Comfortable wi...
    To view a tutorial on first class functions: • JavaScript Question: W...

ความคิดเห็น • 37

  • @RameenFallschirmjager
    @RameenFallschirmjager 4 ปีที่แล้ว +2

    I like your intonation and voice crescendo. In the way that you talk we learners understand the points and concepts better.

  • @kc2838
    @kc2838 4 ปีที่แล้ว +1

    You teach very clearly and to the point. That's a skill not a lot of youtubers have. Subscribed and waiting for more javascript videos.

    • @AllThingsJavaScript
      @AllThingsJavaScript  4 ปีที่แล้ว

      Thanks and welcome

    • @AllThingsJavaScript
      @AllThingsJavaScript  4 ปีที่แล้ว

      I have almost 200 available, so you may want to look at whats out there: th-cam.com/channels/RQhZGXC0WK85YRXl7nGX0w.html?view_as=subscriber

    • @AllThingsJavaScript
      @AllThingsJavaScript  4 ปีที่แล้ว

      Or allthingsjavascript.com/youtube.html

  • @IcarianX
    @IcarianX 5 ปีที่แล้ว +12

    I have no idea where the arguments "a" or "b" are. How does the program determine what variables are passed in as "a" and "b" and what are they?

    • @AllThingsJavaScript
      @AllThingsJavaScript  5 ปีที่แล้ว +9

      By definition sort passes the first two arguments into a and b. It then continues to move through each element of the array.

  • @saeedkhan4927
    @saeedkhan4927 4 ปีที่แล้ว

    I really love your teaching style. Just started Lambda school, and this is really helping me understand the content and material that is being taught. Thank you!

    • @saeedkhan4927
      @saeedkhan4927 4 ปีที่แล้ว

      Just one question, I was following along with your code and I am getting a syntax error. Is this updated to ES6 or does this only apply to ES5 - or does it even matter?

    • @AllThingsJavaScript
      @AllThingsJavaScript  4 ปีที่แล้ว

      Higher order functions have been a part of JavaScript from early on and is still an important aspect of it. So doesn't really matter was ECMAScript release. Post your code if you are still getting an error.

  • @jasonwilliams_escapeimagery
    @jasonwilliams_escapeimagery 7 ปีที่แล้ว +2

    Was so pleased to find your channel some great topics and presentations thanks.

  • @dsnow
    @dsnow 5 ปีที่แล้ว +1

    For reuse and less coupled code, you could define a function expression that performs the comparison that returns a.toLowerCase() - b.toLowerCase() and then pass that function into sort. Nice tutorial.

  • @dembasiby
    @dembasiby 6 ปีที่แล้ว +1

    Great, simple, and to the point. Thanks!

  • @geoffblore
    @geoffblore 3 ปีที่แล้ว

    Thanks for the help!

  • @Corythehausbaus
    @Corythehausbaus 5 ปีที่แล้ว +5

    dude, so many people doing tutorials talk so fast, monotone, and sounds the same the entire time. Not you! Please continue to talk dynamically and really emphasise on the key words!!!!

  • @omleen3187
    @omleen3187 3 ปีที่แล้ว

    Much appreciated for the perfect explanation. Juat one question, please! Which sort algorithm used with javascript sort method? Thanks!

    • @AllThingsJavaScript
      @AllThingsJavaScript  3 ปีที่แล้ว +1

      Good question. I'm not sure which one and it really probably depends on the JavaScript Engine implementation. So technically a browser could use a different algorithm than another one.

    • @mj2758
      @mj2758 3 ปีที่แล้ว +1

      QuickSort and InsertionSort, for smaller arrays

  • @bkleinman123
    @bkleinman123 4 ปีที่แล้ว +1

    How did you know that the sort function takes in another function that has the rules of returns left first if negative number and so on? Is that in a javadoc type thing online that I can look up?

    • @AllThingsJavaScript
      @AllThingsJavaScript  4 ปีที่แล้ว +1

      I don't remember how I first learned it, but I think the MDN pages are great for this kind of thing: developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort

  • @KevinMullarkey
    @KevinMullarkey 2 ปีที่แล้ว

    How would you write this as an 'arrow function'?

    • @AllThingsJavaScript
      @AllThingsJavaScript  2 ปีที่แล้ว

      things.sort((a,b) => {
      let x = a.toLowerCase(),
      y = b.toLowerCase();
      if (x < y) { return -1;}
      if (y < x) { return 1;}
      return 0;
      });

  • @KevinMullarkey
    @KevinMullarkey 2 ปีที่แล้ว

    I keep getting an error 'toLowerCase is not a function'

  • @Shirokeh
    @Shirokeh 7 ปีที่แล้ว

    Thanks for the content. How is progress on the asynchronous course? Have seen it in the status of upcoming and projected release for September for so long!

    • @AllThingsJavaScript
      @AllThingsJavaScript  7 ปีที่แล้ว

      Great Question! I need to go in an update that page. I haven't been able to start that one yet, but it is the next course once I finish up two smaller items I'm working on. I'm adding a section on functional programming to the advanced course and a course on regular expressions. When projects come along, they take priority. There has been a lot of that lately that has slowed me down on the courses.

  • @RameenFallschirmjager
    @RameenFallschirmjager 4 ปีที่แล้ว +1

    Thank you sir for your great explanation. Your tutorials are so compelling that I decided to get your udemy courses too!

  • @sarathbabu7689
    @sarathbabu7689 3 ปีที่แล้ว

    Can able to create my own higher function like map, sort and etc

  • @seenuvasanv
    @seenuvasanv 6 ปีที่แล้ว

    Thanks, really useful..

  • @luismuzquiz1400
    @luismuzquiz1400 7 ปีที่แล้ว

    Steven Could you do a video or a UDEMY course on Vue.js for beginners??

    • @AllThingsJavaScript
      @AllThingsJavaScript  7 ปีที่แล้ว

      That would probably be a course or maybe a series of TH-cam videos to get one started. But I will add it to the list.

  • @shyarxelil1987
    @shyarxelil1987 6 ปีที่แล้ว

    why don't you use els if statment?

    • @AllThingsJavaScript
      @AllThingsJavaScript  6 ปีที่แล้ว

      I do when needed. Are you referring to a specific example?

  • @DopamineMVWM
    @DopamineMVWM 4 ปีที่แล้ว

    why is this guy talking so fucking slow; even on x2 speed its too slow!