in Technology by
how to pass callback function in javascript?

1 Answer

0 votes
by

function functionOne(x) { alert(x); }

function functionTwo(var1, callback) {

    callback(var1);

}

functionTwo(2, functionOne);

function greeting(name) {

  alert('Hello ' + name);

}

function processUserInput(callback) {

  var name = prompt('Please enter your name.');

  callback(name);

}

processUserInput(greeting);

Related questions

0 votes
    How to pass a parameter to an event handler or callback in REACT?...
asked Jun 2, 2021 in Education by JackTerrance
0 votes
    How to pass a map from controller to javascript function in VF page?...
asked Dec 10, 2020 in Technology by JackTerrance
0 votes
    how to pass dynamic string in string javascript?...
asked Dec 10, 2020 in Technology by JackTerrance
0 votes
    I have an html select on my page $query = mysql_query("select * from results"); echo " "; while ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 11, 2022 in Education by JackTerrance
0 votes
    I have an html select on my page $query = mysql_query("select * from results"); echo " "; while ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 6, 2022 in Education by JackTerrance
0 votes
    I have an html select on my page $query = mysql_query("select * from results"); echo " "; while ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 19, 2022 in Education by JackTerrance
0 votes
    Which of the following set the floating-point error callback function or log object? (a) setter (b) settercall (c) setterstack (d) all of the mentioned...
asked Oct 9, 2021 in Technology by JackTerrance
0 votes
    Let's say I have a JSON set of events, each with a start time and end time, and I need to ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 17, 2022 in Education by JackTerrance
0 votes
    Which of the following set the floating-point error callback function or log object? (a) setter (b) ... questions and answers pdf, Data Science interview questions for beginners...
asked Oct 28, 2021 in Education by JackTerrance
0 votes
    What is the purpose of callback function as an argument of setState()?...
asked Jun 2, 2021 in General by JackTerrance
0 votes
    An expression is a JavaScript object that you pass to the compiled template a)False b)True...
asked Dec 11, 2020 in Education by Editorial Staff
0 votes
    I have the following child component: class SignIn extends React.Component { constructor(props) { super(props ... for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 26, 2022 in Education by JackTerrance
0 votes
    I have the following child component: class SignIn extends React.Component { constructor(props) { super(props ... for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 21, 2022 in Education by JackTerrance
0 votes
    _________ require you to pass a function whose argument is a vector of parameters. (a) optimize() (b) ... Debugging of R Programming Select the correct answer from above options...
asked Feb 15, 2022 in Education by JackTerrance
0 votes
    Suppose we run the multistage algorithm on the data of exercise 6.3.1, with the same support threshold of 4. ... set of candidate pairs Select the correct answer from above options...
asked Nov 28, 2021 in Education by JackTerrance
...