Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Small JS exercises
/**
* 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
You can’t perform that action at this time.