This file contains 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.prototype.mybind = function (context, ...args1) { | |
let fn = this; | |
return function (...arg2) { | |
fn.apply(context, [...args1, ...arg2]) | |
} | |
}; |
This file contains 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 urls = [ | |
'https://api.github.com/users/iliakan', | |
'https://remy.com', | |
'https://api.github.com/users/jeresig' | |
]; | |
Promise.all( | |
urls.map(url => | |
fetch(url) | |
.then(r => r.json()) |
This file contains 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 clear; | |
function calling (param, time) { | |
clearTimeout(clear); | |
var promise = new Promise(function(resolve, reject) { | |
clear = setTimeout(() => resolve(param), time); | |
}); | |
promise.then(r => console.log('Do whatever you want', r)); | |
} |