Skip to content

Instantly share code, notes, and snippets.

@rahulbanerjee26
Created July 6, 2022 04:11
Show Gist options
  • Save rahulbanerjee26/daef042bee9f8fb25c0f8abad22e63d5 to your computer and use it in GitHub Desktop.
Save rahulbanerjee26/daef042bee9f8fb25c0f8abad22e63d5 to your computer and use it in GitHub Desktop.
let names = ['Rahul','Rohit','Rohan']
function addNewName(name, cb){
setTimeout(function(){
names.push(name)
cb()
},5000)
}
function printNames(){
setTimeout(function(){
console.log(names)
},3000)
}
addNewName('Alex',printNames)
// Output:
// [ 'Rahul', 'Rohit', 'Rohan', 'Alex' ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment