Skip to content

Instantly share code, notes, and snippets.

@prof3ssorSt3v3
Created July 23, 2017 15:17
Show Gist options
  • Save prof3ssorSt3v3/b8c2f85332746d72648d592891f161ab to your computer and use it in GitHub Desktop.
Save prof3ssorSt3v3/b8c2f85332746d72648d592891f161ab to your computer and use it in GitHub Desktop.
// Callback functions
//built-in callback functions
//setTimeout, Arr.forEach, geolocation.getCurrentPosition
//make your own callback functions
//setTimeout( hello, 2000, 'Bob')
let names = ['Inga','Tom','Mattias','Carlos'];
names.forEach(hello);
navigator.geolocation.getCurrentPosition(gotPosition, positionError, {});
function gotPosition(pos){
}
function positionError(err){
}
function doThing(other){
let x = 7;
//do lots of other things
//...
let name = 'Steve';
other(name);
}
function hello(nm, idx, arr){
console.log('hello', nm);
}
/**
doThing(hello);
**/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment