Skip to content

Instantly share code, notes, and snippets.

View oahehc's full-sized avatar

Andrew oahehc

View GitHub Profile
const a = () => (
new Promise((res) => {
console.log('-- a start');
setTimeout(() => {
console.log('a');
res('-- a finish');
}, 1000)
})
)
const b = () => (
@oahehc
oahehc / closure.js
Created July 23, 2018 00:48
js closure
function f(a) {
return function(b) {
console.log(a, b);
}
}
var func = f('123');
func('321'); // 123 321
@oahehc
oahehc / this.js
Last active July 22, 2018 14:22
javascript: this
var func = {
f1: function() {
console.log('f1', this);
var sub = function () {
console.log('sub', this);
};
sub();
},
f2: () => {
console.log('f2', this);