Тёмный

JavaScript Callbacks Explained in 5 Minutes (Essential for asynchronous code!) 

James Q Quick
Подписаться 201 тыс.
Просмотров 137 тыс.
50% 1

You must understand JavaScript Callbacks to understand the basics of asynchronous JavaScript.
Callbacks are functions that get passed as a parameter to another function. This is made possible by the fact that functions are first-class citizens in JavaScript and they are commonly used as a way to notify that some action has been completed.
STAY IN TOUCH 👋
Check out the Podcast - compress.fm
Newsletter 🗞 - www.jamesqquick.com/newsletter
Live streams on Twitch 🖥️ - / jamesqquick
Follow me on Twitter 🐦 - / jamesqquick
QUESTIONS...?
Join the Discord Server 💬 - / discord
Want to know what hardware and software I use? www.jamesqquick.com/uses
Learn Web Development 📖 - www.jamesqquick.com/courses

Опубликовано:

 

5 июл 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 176   
@fliplucky8813
@fliplucky8813 Год назад
1, 3, 2 it will firstly fire off all the functions from the stack. When the stack is completed, it will go over all the events
@nevergonnabesilent
@nevergonnabesilent Год назад
you win the prize. this is why i love javascript
@moeyali123
@moeyali123 10 месяцев назад
i couldnt understand this until i learnt how the stack worked
@kraptastic333
@kraptastic333 28 дней назад
@@moeyali123 any resources you might share?
@Mr.PolyMath
@Mr.PolyMath Год назад
excellent video mate!! bitesize knowledge for JS is so much more useful than sitting through anything longer where the person starts to waffle. Your examples are great too and extremely well scaffolded!!
@hamidturkistani734
@hamidturkistani734 4 месяца назад
I have never learned a programming concept just in 12 seconds. Keep up the good work James.
@nevergonnabesilent
@nevergonnabesilent Год назад
I love how succinctly you explain things. Instead of using a bunch of terms that only advanced developers understand. You're meat and potatoes when it comes to teaching. Keep it up!
@Anarki9891
@Anarki9891 Год назад
Nice explanation. A video on the different ways to define a function in JavaScript and when they should be used would be helpful.
@JamesQQuick
@JamesQQuick Год назад
Yeah that’s a great idea!
@hristopisarev1827
@hristopisarev1827 Год назад
Very simple and well explained. Thank you!
@chadtarpey2578
@chadtarpey2578 Год назад
Awesome James . Love the oil change analogy .
@perminusgaita
@perminusgaita Год назад
The mechanic example made me understand everything really fast. Thank you 🙂
@thebarnold7234
@thebarnold7234 Год назад
This is actually really useful. Helped me understand my really weird bug when developing a chrome extension
@SirGuacJulio
@SirGuacJulio Год назад
This helped me a lot you explain things fantastically!
@jonathanrafaelpetitrojas9949
Excelente video, claro y al punto! 💪💪
@tommih86
@tommih86 5 месяцев назад
Thanks. Very nicely explained! Got it.
@charlesE89
@charlesE89 Год назад
Fantastic explanation, thank you!
@Bellathor
@Bellathor 10 месяцев назад
Thanks, I needed a refresher. Great video.
@JamesQQuick
@JamesQQuick 10 месяцев назад
So glad it helped!
@morecoredesigner
@morecoredesigner Год назад
Thanks James great video.
@kutsoji
@kutsoji Год назад
YOURE SO DAMN AMAZING! I mean, its kinda sad that I've saw you for the first time after like 2 years of starting coding but it's worth it anyways, best dev channel, keep it up!
@willyhorizont8672
@willyhorizont8672 Год назад
Awesome tutorial James. Would you do make video about nested async callback function too ?
@Softon_tv
@Softon_tv Год назад
I gave you like immediatelly when I saw how easily and well you explain everything and later when I saw pokemon example which I really liked I wanted to give you another like but then I realised I already did it so I gave you subscription. well done ^_^
@mbaljeetsingh
@mbaljeetsingh Год назад
1,3,2 setTimeout (Web APIs -> Task Queue -> Call Stack (using event loop). It'll only run after the synchronous operation is done.
@oncoding4520
@oncoding4520 11 месяцев назад
love your content. always a supporter of your content James.
@JamesQQuick
@JamesQQuick 11 месяцев назад
Thank you so much!
@Rahuldhingra-nx3vm
@Rahuldhingra-nx3vm Месяц назад
Brilliant explanation! Efficiency at its best 👌🏻
@alessandrogiuzio
@alessandrogiuzio Год назад
Thank you James!
@psaintjean11
@psaintjean11 13 дней назад
Very well explained for beginners like myself. This is very useful. Thank You for sharing.🎉🎉
@rheavictor7
@rheavictor7 4 месяца назад
Thanks for the lesson, you have a gift of being concise and provide valuable information!
@JamesQQuick
@JamesQQuick 4 месяца назад
So glad to hear that!
@haroldtien2213
@haroldtien2213 Год назад
thanks for precise explain, only one that make me understand
@user-xz3ws9lz1o
@user-xz3ws9lz1o Год назад
very clear,wonderful!!
@JamesQQuick
@JamesQQuick Год назад
Yay, thank you!
@klaudiadev
@klaudiadev 11 месяцев назад
excellent explanation! 👏🏽
@alandmcleod5988
@alandmcleod5988 8 дней назад
Nice and easy walkthru. Thx so much
@kenzafilali9115
@kenzafilali9115 Год назад
Just discovered this chanel and I am hitting the subscribe button without any hesitation.. Keep going any tutorial for rest api and react ?
@techlightdev
@techlightdev Год назад
So nice, Thank you for tutorial
@voicingmymind7517
@voicingmymind7517 10 месяцев назад
I am coming from the Odin Project. I am still fairly a beginner so I more or less didn't quite understand a lot. I was interested to understand what were call back functions. Will for sure come back later for a deeper dive in functions. I am sure you have a great explanation.
@theopogo9159
@theopogo9159 16 дней назад
I feel this. I've been coding for 4 months and my mentor pushed me to this topic. I am way over my head and need to go back for some fundamentals practice
@ravish8620
@ravish8620 Год назад
Really this is helpfull. Thank you
@filip23128
@filip23128 Год назад
Thanks James!
@gooo1762
@gooo1762 4 месяца назад
thanks so much!!
@khalidelgazzar
@khalidelgazzar Год назад
Great video .. thanks 😃👍
@JamesQQuick
@JamesQQuick Год назад
Glad you enjoyed it!!
@rccmhalfar
@rccmhalfar Год назад
Hi James definetly would be nice to have a 5min video on es6 arrow functions
@JamesQQuick
@JamesQQuick Год назад
Absolutely!
@fargoflagrant7796
@fargoflagrant7796 Год назад
Thank you!
@boristheblad
@boristheblad Год назад
Thanks for the video
@travelnlearn
@travelnlearn 8 месяцев назад
very nice effective & efficient video
@JamesQQuick
@JamesQQuick 8 месяцев назад
Yay! Glad to hear it!
@RohitGorain-xo7du
@RohitGorain-xo7du 10 дней назад
1,3,2 cause async tasks are taken care by the event loop, and event loop monitor that the stack should always be empty, if empty then it will take the CB(call back) to stack and callstack will immediately execute the CB
@josemanuelvialopez1488
@josemanuelvialopez1488 Год назад
I couldn't understand the concept of cb function even watching videos in my language (spanish), your explanation was definetely the best by far. Thank you very much
@JuanMontes-xo4th
@JuanMontes-xo4th Год назад
WOWWWWWWWW! I JUST GOT IT, THIS IS SO POWERFUL!!!!
@JamesQQuick
@JamesQQuick Год назад
Yeahhhhh!!
@abiddeveloper1
@abiddeveloper1 Год назад
that was quick, and quickly you have a subscriber.
@JamesQQuick
@JamesQQuick Год назад
hehe thanks!
@dajucoder
@dajucoder 2 месяца назад
Hey, please tell me: 1. What theme are you using for the ide 2. How does your cursor is blinking such cool way
@bucifalro
@bucifalro Год назад
how would you make the example behave synchronous, in order to yield 1,2,3 ?
@navinduabhishek8564
@navinduabhishek8564 Год назад
Thanks a lot!💌 and Could u tell me what theme u use in vs code?😊
@kigler43
@kigler43 Год назад
thank you, cool video
@mikehotel5652
@mikehotel5652 Год назад
I like the explanation with the oil change. It would be nice, if the example code resembles the oil change, to transfer this conversation to JS. Anyways. Good explanation.
@sayedmuzahid4451
@sayedmuzahid4451 Год назад
excellent 🔥
@inversionero
@inversionero Год назад
What theme are you using in your VSCode? It's so clean to see.
@ProtonCoder
@ProtonCoder Год назад
Shades of purple
@tesfamichaelalmaw
@tesfamichaelalmaw 4 месяца назад
what kind of theme are you using on your vs code pls?
@ericcrowell9493
@ericcrowell9493 Год назад
Great little tutorial! By the way, what font do you use in this video? I really like it!
@JamesQQuick
@JamesQQuick Год назад
Cascadia code :)
@Douwnuts07
@Douwnuts07 10 месяцев назад
thanks. greetings from ph
@firosiam7786
@firosiam7786 Год назад
What is difrnce between callbcaks and closures does both simply help put a function within a function
@rmiliming
@rmiliming Год назад
LOL. You are so humerus ! I get the idea quickly thank you!
@ragnar_9083
@ragnar_9083 11 месяцев назад
Liked and subscribed just for the mere fact you like pokemon, too. Great video! thanks!
@JamesQQuick
@JamesQQuick 10 месяцев назад
I'll take it!
@paulclarke4099
@paulclarke4099 Год назад
Would love to see a practical real world example of why and where you would use Currying, most people always show non real world useless non practical examples. Thanks for all your great videos James 😃 👍
@everyhandletaken
@everyhandletaken Год назад
Just when I re-visit & think I see the purpose of currying, I then forget all about it immediately after not finding a real world use. Very much agree
@rajeshpoddar5763
@rajeshpoddar5763 Год назад
Can you make project using web worker? To understand about using web worker.
@raflyardiansyah4598
@raflyardiansyah4598 5 месяцев назад
I don't know if you're still answering questions but what kind of vscode theme do you use that looks awesome
@scottumphrey1769
@scottumphrey1769 8 месяцев назад
Very goo video. Thanks. S-
@JamesQQuick
@JamesQQuick 7 месяцев назад
Glad you liked it!
@celsomomade
@celsomomade 5 месяцев назад
Great tutorial. Thanks What's the font are you using?
@maandawod2744
@maandawod2744 3 месяца назад
Cascadia Code
@coffeecode
@coffeecode Год назад
Pretty cool !
@JamesQQuick
@JamesQQuick Год назад
Thanks for watching ;)
@lernkunst6291
@lernkunst6291 5 месяцев назад
3:05, line 3, does the first (name) needs brackets?
@ayushlalotra1192
@ayushlalotra1192 6 месяцев назад
Can i know the theme you are using in vs code
@tharakakarunarathne2420
@tharakakarunarathne2420 Год назад
at 1:40 why did he has to swap the codes? arn't functions run where ever there in javascript? Some one pls explain
@francsicozuniga3721
@francsicozuniga3721 Год назад
Hi, what software are you using in this video to do the actual coding? Can anybody provide me an answer, please
@ghaithjr.9189
@ghaithjr.9189 Год назад
clearly vs code
@jonathanrafaelpetitrojas9949
Me encantaría una lista de reproducción sobre cómo consumir apis. con este tema y otros en los que un principiante suele luchar
@JamesQQuick
@JamesQQuick Год назад
Ah buena idea! Yo la anadire al “backlog” :)
@meysythet9092
@meysythet9092 Год назад
What name of background theme you use
@crust5532
@crust5532 Год назад
Can anyone tell me the VS code theme used here?
@itznapster455
@itznapster455 Год назад
shades of purple
@subiebugeye02
@subiebugeye02 Год назад
I need your help with arrow functions lol please James thx
@sanjitjena4954
@sanjitjena4954 Год назад
So unless I don't read the documentation, I cannot know the number and type of the parameters of that callback function.
@oussamaguezguez6090
@oussamaguezguez6090 8 месяцев назад
Hello James! the functions loadPokemon how is it asynchronous? is it because fetch is asynchronous ?
@JamesQQuick
@JamesQQuick 8 месяцев назад
Yep the function has to be marked as async because we use await for the async fetch call.
@tristanlukens7158
@tristanlukens7158 Год назад
iirc the example should log out 1 3 2, since setTimeout() is a macrotask. It's been a while since I delved into async javascript tho
@JamesQQuick
@JamesQQuick Год назад
Love it!
@advitiyasood5034
@advitiyasood5034 Год назад
is there a way to output 1,2, 3 instead?
@BirbyOnTwitch
@BirbyOnTwitch 5 месяцев назад
I'm confused, why would you not just use await, for example: let result = await someFunction(); console.log(result) Doesn't this achieve the exact same thing?
@oussamahamdi6993
@oussamahamdi6993 Год назад
1, 3, 2 because of the event loop
@derickasane8499
@derickasane8499 11 месяцев назад
greatone
@cecibenitez3917
@cecibenitez3917 Год назад
1, 3 and 2 😊👌
@JamesQQuick
@JamesQQuick Год назад
Nice!
@rean8899
@rean8899 Год назад
Could you please create video that show how to solve the uncheck runtime.lastError in Chrome and how to turn off Debugger on Chrome as well. It's too annoying.
@andruvasiliu7036
@andruvasiliu7036 Год назад
If I were you, I would definitely name my two dogs Ekans and Koffing
@iliashterev38
@iliashterev38 6 месяцев назад
James, please help me understand something. It is one last JS weirdness left for me that I can't grasp having strong C# background. I will try the simplest example I can think of. So each JS developer say it should be like this: function simpleCallbackFn (){} function simpleCallerFn (cb){ cb();} simpleCallerFn (simpleCallbackFn); Why not like this: function simpleCallbackFn (){} // Same as before function simpleCallerFn (){ simpleCallbackFn ();} // We do not pass a callback, we simply call the it from within. It is within perfectly visible scope. simpleCallerFn (); We call the "callback" function from within the caller function and to me this should be perfectly fine and achieve the same result. Thank you. Greetings from Bulgaria. Well, trying to please you :) . And to be nice.
@jonathanrafaelpetitrojas9949
I learned more in this video about callbacks than in 2 semesters of computer science... Thank you so much!!
@R3fuge
@R3fuge Год назад
Sounds like you went to the wrong university
@jonathanrafaelpetitrojas9949
@@R3fuge it happens a lot in latin america.
@JamesQQuick
@JamesQQuick Год назад
Glad it was helpful!
@rashidanwar101
@rashidanwar101 7 месяцев назад
Which font are you using?
@maandawod2744
@maandawod2744 3 месяца назад
Cascadia Code
@lukeburghard879
@lukeburghard879 День назад
What is the difference between function foo(){} and let foo = ()=>{}
@dhadveyash2268
@dhadveyash2268 7 месяцев назад
Now i am more confused, cant i just use that callback function directly without calling it as variable in the function
@nihadkv303
@nihadkv303 Год назад
♥️♥️♥️
@theidanking
@theidanking 9 месяцев назад
I still didnt understand how does cb() work, what is it doing
@gkugathas
@gkugathas 8 месяцев назад
1,3 and 2
@richk5015
@richk5015 3 месяца назад
1,3,2, even with setTimeout 0 it'll be 1,3,2
@nouhabc194
@nouhabc194 Год назад
please what is this text editor
@mykolapetrovych3660
@mykolapetrovych3660 11 месяцев назад
That's what I wanted to know.
@ranbirsaini3009
@ranbirsaini3009 11 месяцев назад
1,3,2
@tomich20
@tomich20 Год назад
great, now please add the async await in all that stuff. Cause thats what makes it confusing to new developers.
@JamesQQuick
@JamesQQuick Год назад
Good idea!
@winspyre
@winspyre Год назад
you explained it in 60 seconds actually.
@reluminopraha5948
@reluminopraha5948 11 месяцев назад
Lost with those arrows 😢
@shaikhyamin3464
@shaikhyamin3464 Год назад
1 ,3 ,2 , if you have knowledge about event loop then you will get this
@JamesQQuick
@JamesQQuick Год назад
That's right!
@syedarmaghanhassan4652
@syedarmaghanhassan4652 10 месяцев назад
Excellent example in the beginning.. just too fsst later.. 😅
@JamesQQuick
@JamesQQuick 10 месяцев назад
Ah sorry to hear that. Thanks so much for the feedback!
@LevelUpLifeYT
@LevelUpLifeYT Год назад
2, 1, 3
@aingaran_com
@aingaran_com Год назад
As a dad joke connaisseur, I appreciate your similary cheesy intro jokes.
@Farid-Khan
@Farid-Khan 26 дней назад
Output: 1 3 2
@ejazalam6512
@ejazalam6512 11 месяцев назад
i understand callbacks in starting 15 sec
@JamesQQuick
@JamesQQuick 11 месяцев назад
Good work!
@dailyrisktaker6211
@dailyrisktaker6211 2 месяца назад
Easy Subscribe 😁!!
Далее
Learn JavaScript CALLBACKS in 7 minutes! 🤙
7:17
Просмотров 38 тыс.
Stray Kids <ATE> UNVEIL : TRACK "Stray Kids"
01:28
Gặp 2 thánh troll | CHANG DORY | ometv
00:42
Просмотров 13 млн
Callbacks in JavaScript Explained!
14:03
Просмотров 150 тыс.
Tips For Using Async/Await in JavaScript
16:26
Просмотров 395 тыс.
JavaScript ES6 Arrow Functions Tutorial
9:32
Просмотров 819 тыс.
What is JavaScript CALLBACK HELL? 🔥
5:49
Просмотров 17 тыс.
Learn React Hooks: useCallback - Simply Explained!
17:15
Node.js is a serious thing now… (2023)
8:18
Просмотров 631 тыс.
Stray Kids <ATE> UNVEIL : TRACK "Stray Kids"
01:28