Answer the question
In order to leave comments, you need to log in
Is calling a function in a function (callback) an asynchronous operation in JS?
I am studying asynchronous programming in JS, tell me if callback is an "asynchronous operation" in JS?
...callback.apply(callbackObj, [firstName, lastName]);...
( function () {
"use strict" ;
var clientData = {
id : 94545,
fullName : "Not Set",
setUserName : function (firstName , lastName) {
this. fullName = firstName + " " + lastName;
}
};
function getUserInput(firstName, lastName, callback , callbackObj) {
//Вызов метода. Вызывается ли данный метод асинхронно?
callback.apply(callbackObj, [firstName, lastName]);
// Some action after callback running
}
getUserInput ("Barack", "Obama", clientData.setUserName, clientData );
console.log( clientData.fullName);
}());
Answer the question
In order to leave comments, you need to log in
Of course not. You simply call the function and ensure that this when it is executed will have a reference to the first parameter passed.
By itself, calling any method is synchronous code. Be it at least setTimeout() , at least new XMLHttpRequest().send() .
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question