-
-
Save tihozdjelarevic/0e2d5ac8698088cc13507e210ecd0a7a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 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