Last active
January 19, 2018 12:45
-
-
Save martpie/c4d92980454daf5f90ba22aa6beec55c to your computer and use it in GitHub Desktop.
Small JS exercises
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
/** | |
* Small JS exercices | |
* Consider all exercises independant from each other and running in their own scope | |
* | |
*/ | |
/** | |
* What is the output of this piece of code? | |
* | |
*/ | |
console.log(0); | |
setTimeout(() => { console.log(1) }, 2000); | |
setTimeout(() => { console.log(2) }, 0); | |
console.log(3); | |
/** | |
* What is the output of this piece of code? | |
* | |
*/ | |
console.log(a); | |
a = 1; | |
console.log(a); | |
function a() { | |
console.log(2) | |
} | |
console.log(a) | |
/** | |
* Implement a mini-event library | |
* | |
*/ | |
minievent.on('test', () => { | |
console.log('That is an event'); | |
}); | |
minievent.emmit('test'); | |
function minievent() { | |
// ... | |
this.on = () => { | |
// ... | |
} | |
this.emit = () => { | |
// ... | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment