Answers for "how to create custom callback function in javascript"

0

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);
Posted by: Guest on October-19-2021

Code answers related to "how to create custom callback function in javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language