JavaScript Callback Functions Explained #fullstackroadmap (Ep. 6.1)

preview_player
Показать описание
This is part of my Frontend Web Development Course for Beginners. Learn the basics of HTML, CSS, and JavaScript to build a solid foundation for web development.

You can find resources and other information for this video at the Full Stack Foundations link below:

-------------------------------------------------------------------------------------

Connect with me:

-------------------------------------------------------------------------------------

Timestamps:

0:00 Intro
1:05 Writing a callback function
10:26 The 2 main reasons we need callbacks
Рекомендации по теме
Комментарии
Автор

Waiting for asynchronous programming Videos. Please make them a bit longer!!

siddheshswami
Автор

Ohhh Man !!! THanks a Lot !!! I understood the whole concept in the very first minute when i saw the two different functions you showed initially. THanks a lot It really helped a lot.
I'm literally waiting for your next video on Asynchronous programming video on promise and all that. I'm now sure that those will also be super amazing like this one explain and clear all my doubts around it. Thank you Zach :) You aren't good, You are an Awesome Teacher!!

contactdi
Автор

In your very first example (before the map ex.) you could call myCallback(someNumber) from inside mainFunction without ever sending it. It is within the scope and can be called like

mainFunction(randomNumber, shouldCall) {

myCallback(randomNumber) ;

}

Thank you.
Ilia

mocococo
Автор

I am having a problem at approx7:55. This example is not working for me. I made a local webpage to test all code and work on without having a terrible number of errors in the console, and have them in Notepad instead, and in the first example I did get the 40 - the code was easily followed. But he second example the callBack function is never defined or called and I get a value of 0 (zero) so what am I doing wrong? The code used is:

///now another way which I can't see working
function anotherFunction(randomNumber, shouldCall, thecallBack){
let result=randomNumber;

//shouldCall will equal true
if(shouldCall){
//how will it call the function when there is no parameter or a function even made


}
return result;
}

function called with:

thevalue = anotherFunction(20, true, (num) => num*2);

There is no function called nor a callback function even defined or sent in the parameters! Please someone respond!

vaughanmacegan
Автор

@1:09 How can you call a function named 'callBack()' when it is not even defined in the code anywhere.

tanveermughal
Автор

It is really confusing for me (13:00) when you map through each element of an array and call a function As this function is expecting parameter of "ItemFromArray" in its definition. But within the map function, you are passing nothing to this function.

shafiullah