Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

how to create custom callback function in javascript

var users = ["Sam", "Ellie", "Bernie"];

function addUser(username, callback)
{
    setTimeout(function()
    {
        users.push(username);
        callback();
    }, 200);
}

function getUsers()
{
    setTimeout(function()
    {
        console.log(users);
    }, 100);
}

addUser("Jake", getUsers);
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #create #custom #callback #function #javascript
ADD COMMENT
Topic
Name
1+5 =