• Friday , 15 December 2017

Javascript – How to Use Callbacks

Code Canyon



a callback is a function that is passed as an argument to another function, this makes functions more flexible

the callback is invoked inside the function

you can also use an anonymous function as a callback

the use of callbacks is very common, and are used often

———————————————————–
http://atechapart.com | http://linkedin.com/in/alvinsanchez

see my codepens @ http://codepen.io/_asanchez/

Original source

3d Ocean

Related Posts

34 Comments

  1. Rj Simas
    November 30, 2017 at 00:46

    This is by far the best video online explaining callbacks. Thank you.

  2. Егор Хейз
    November 30, 2017 at 00:46

    Thank u so much!

  3. Isaac Home
    November 30, 2017 at 00:46

    I m confused when to use parameter in function .Could make expliantion for me .Pls . 😀

  4. Jobille Photography
    November 30, 2017 at 00:46

    A Tech Apart Thank you for the straight to the point explanation.
    does it matter if you called the function "useCallback" below it or before it?
    is it a good practice?

  5. David Dolynny
    November 30, 2017 at 00:46

    thanks

  6. atom
    November 30, 2017 at 00:46

    quick and to the point!

  7. Amol Patil
    November 30, 2017 at 00:46

    What is the difference if I write code like below?

    useCallback(4);

    function useCallback(x) {
    document.write(x);
    calbackX();
    }

    function callbackX() {

    }

  8. MrRossss1
    November 30, 2017 at 00:46

    Great Vid thanks

  9. wuz352
    November 30, 2017 at 00:46

    David Schwimmer is a solid JS narrator! Many thanks, man.

  10. ronP __
    November 30, 2017 at 00:46

    use a Lav mic instead of a desktop (same surface as your keyboard) so it doesn't sound like your using a hammer on your keyboard?

  11. okeken
    November 30, 2017 at 00:46

    excellent explanation!

  12. oceej0
    November 30, 2017 at 00:46

    Thanks, I'm starting to get it, I've encountered it before and was left stumped. Examples, I could follow. I had to stop and think about what was being done, and that combined with the output removed some of the fog swirling around this topic. Thanks again.

  13. Jessé Marques
    November 30, 2017 at 00:46

    Perfect, muito obrigado!!!!!!!!!

  14. Kelvin Fok
    November 30, 2017 at 00:46

    Great video! Clear and concise! You should consider doing a series of tutorial videos 🙂

  15. Kira Chan
    November 30, 2017 at 00:46

    Jesus, I would hate to be your keyboard fam

  16. Best Playlists Ever
    November 30, 2017 at 00:46

    Very cool. I'm starting to see the light.

  17. 1flymagician
    November 30, 2017 at 00:46

    THX 🙂

  18. davidkhd
    November 30, 2017 at 00:46

    hangover? 😀

  19. Joe Antonelli
    November 30, 2017 at 00:46

    nice video – but why are you so angry with your keyboard?

  20. Andriy Shtoyko
    November 30, 2017 at 00:46

    your video s simply genious as all genius is simle)

  21. Patrick Duff
    November 30, 2017 at 00:46

    I really enjoyed this video, a wonderful introduction to callbacks!

  22. codeChris
    November 30, 2017 at 00:46

    excellent. short simple and sweet

  23. codeChris
    November 30, 2017 at 00:46

    excellent. short simple and sweet

  24. codeChris
    November 30, 2017 at 00:46

    excellent. short simple and sweet.

  25. codeChris
    November 30, 2017 at 00:46

    excellent. short simple and sweet.

  26. Rogue3021
    November 30, 2017 at 00:46

    Quick and clear explanation. Thanks man.

  27. Ritchie R
    November 30, 2017 at 00:46

    I think I got it .

    function person(name, gender, callback){

    N = name.toUpperCase();
    G = gender.toUpperCase();
    callback(N,G);

    }

    function show_person(arg1, arg2){

    console.log(arg1, arg2);
    }

    person("Ritchie", "male", show_person)
    person("Max", "male", show_person)

  28. Ritchie R
    November 30, 2017 at 00:46

    Thanks for the video. Things start to get tricky when arguments are passed to the callback. I'm barely starting to understand this. I was wondering what you were gonna name the anonymous function then I was like oh yea duh lol.

  29. Evert Kors
    November 30, 2017 at 00:46

    Thank you!

  30. Say Hong Tan
    November 30, 2017 at 00:46

    I think you have the best examples for callback functions.

  31. faizn vartji
    November 30, 2017 at 00:46

    Thank you so much for explaining this.
    most simplest explaination possible.

  32. Sam Pepper
    November 30, 2017 at 00:46

    Helped me get a grasp of the basics. Thank you!

  33. JayDee
    November 30, 2017 at 00:46

    Most helpful 5 minutes of my life. Thank you.

  34. Rares Ghinga
    November 30, 2017 at 00:46

    waste of time

Leave A Comment

You must be logged in to post a comment.