Skip to content

Instantly share code, notes, and snippets.

@JiaLiPassion
Created October 20, 2018 23:49
Show Gist options
  • Save JiaLiPassion/e895833cd150854ffa56c88fdaacb1eb to your computer and use it in GitHub Desktop.
Save JiaLiPassion/e895833cd150854ffa56c88fdaacb1eb to your computer and use it in GitHub Desktop.
async function detect() { }
const r = detect();
const nativeThen = r.__proto__.then;
r.__proto__.then = function () {
console.log('promise.then');
return nativeThen.apply(this, arguments);
}
async function test1() {
console.log('before await');
const r = await test();
console.log('after await');
}
test1();
console.log('end');
// the output will be
// before await
// end
// promise.then, question is why promise.then is after end?
// after await
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment