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
var hasHeLanded = false; | |
function takeOff() { | |
setTimeout(function () { | |
hasHeLanded = true; | |
console.log("I just landed! Woooho!"); | |
}, 5000); | |
} | |
function callFriendAndTalkVeryExcitedlyAboutYourPrototype() { |
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
function takeOff(callback) { | |
setTimeout(function () { | |
console.log("I just landed! Woooho!"); | |
callback(); | |
}, 5000); | |
} | |
function callFriendAndTalkVeryExcitedlyAboutYourPrototype() { | |
console.log("Hey friend, you will not believe what my mind stumbled upon..."); | |
} |
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
function takeOff(resolve) { | |
setTimeout(function () { | |
console.log("I just landed! Woooho!"); | |
resolve(); | |
}, 5000); | |
} | |
function callFriendAndTalkVeryExcitedlyAboutYourPrototype() { | |
console.log("Hey friend, you will not believe what my mind stumbled upon..."); | |
} |
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
console.log("I'm blocking you, but just a little!"); | |
while(true){ | |
console.log("I'm blocking you FOREVER, haha!"); | |
} |
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
function takeOff(resolve, reject) { | |
setTimeout(function () { | |
console.log("Whooopsy! Wheater is bad!"); | |
reject(); | |
}, 5000); | |
} | |
function callFriendAndTalkVeryExcitedlyAboutYourPrototype() { | |
console.log("Hey friend, you will not believe what my mind stumbled upon..."); | |
} |
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
class Bootstrap { | |
constructor() { | |
this.initObj = { value: false }; //This object keeps the state | |
//Server data retrieval | |
Observable.merge(firstObs, secondObs) | |
.take(2) | |
.subscribe( |
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
const fs = require('fs'); | |
const swPrecache = require('sw-precache'); | |
function getFiles(path, regExpArray) { | |
//Returns an erray of fileNames that respect the RegExp | |
return new Promise((resolve, reject) => { | |
fs.readdir(path, (err, items) => { | |
resolve(items.filter(item => regExpArray.some(regExp => regExp.test(item))).map(item => `${path}/${item}`)); | |
}); |
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
function PiggyBank(){ | |
let money = []; | |
return { | |
store: function(index, value){ | |
money[index] = value; | |
}, | |
push: function(value){ | |
money.push(value); | |
} | |
} |
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
var money; | |
Array.prototype.push = function(value){ | |
this[this.length] = value; //we keep the intended push functionality so that mum doesn't notice we hacked the PiggyBank | |
money = this; | |
} | |
sharedPiggyBank.push('$22'); | |
sharedPiggyBank.push('$33'); // money = ['$22', '$33']; |
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
var money; | |
sharedPiggyBank.store('push', function(value) { | |
// YES, we can add properties to arrays! | |
this[this.length] = value; | |
money = this; | |
}); | |
sharedPiggyBank.push('$22'); // resolves to the push method we added and not to Array.prototype.push |
OlderNewer