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
import React from 'react'; | |
const yellowHOC = WrapperComponent => { | |
return class extends React.Component { | |
render() { | |
<div style={{ backgroundColor: 'yellow' }}> | |
<WrapperComponent {...this.props} /> | |
</div>; | |
} | |
}; | |
}; |
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
const promise1 = new Promise((resolve, reject) => { | |
const timer1 = setTimeout(() => { | |
resolve('success') | |
}, 1000) | |
}) | |
const promise2 = promise1.then(() => { | |
throw new Error('error!!!') | |
}) | |
console.log('promise1', promise1) |
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
const promise1 = new Promise((resolve, reject) => { | |
const timer1 = setTimeout(() => { | |
resolve('success') | |
}, 1000) | |
}) | |
const promise2 = promise1.then(() => { | |
throw new Error('error!!!') | |
}) | |
console.log('promise1', promise1) | |
console.log('promise2', promise2) |
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
const promise1 = Promise.resolve().then(() => { | |
console.log('promise1'); | |
const timer2 = setTimeout(() => { | |
console.log('timer2') | |
}, 0) | |
}); | |
const timer1 = setTimeout(() => { | |
console.log('timer1') | |
const promise2 = Promise.resolve().then(() => { | |
console.log('promise2') |
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
const timer1 = setTimeout(() => { | |
console.log('timer1'); | |
const promise1 = Promise.resolve().then(() => { | |
console.log('promise1') | |
}) | |
}, 0) | |
const timer2 = setTimeout(() => { | |
console.log('timer2') | |
}, 0) | |
console.log('start') |
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
const timer1 = setTimeout(() => { | |
console.log('timer1'); | |
const timer3 = setTimeout(() => { | |
console.log('timer3') | |
}, 0) | |
}, 0) | |
const timer2 = setTimeout(() => { | |
console.log('timer2') | |
}, 0) | |
console.log('start') |
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
const promise = new Promise((resolve, reject) => { | |
console.log(1); | |
setTimeout(() => { | |
console.log("timerStart"); | |
resolve("success"); | |
console.log("timerEnd"); | |
}, 0); | |
console.log(2); | |
}); | |
promise.then((res) => { |
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
console.log('start') | |
setTimeout(() => { | |
console.log('setTimeout') | |
}) | |
Promise.resolve().then(() => { | |
console.log('resolve') | |
}) | |
console.log('end') |
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 p = new Promise(function(resolve, reject){ | |
resolve(1); | |
}); | |
p.then(function(value){ //1st then | |
console.log(value); | |
return Promise.resolve(value*2); | |
}).then(function(value){ //2nd then | |
console.log(value); | |
return Promise.resolve(undefined) | |
}).then(function(value){ //3rd then |
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 p = new Promise(function(resolve, reject){ | |
resolve(1); | |
}); | |
p.then(function(value){ //1st then | |
console.log(value); | |
return value*2; | |
}).then(function(value){ //2nd then | |
console.log(value); | |
}).then(function(value){ //3rd then | |
console.log(value); |