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
The nativePromise.then will be executed after end, I don't understand why, any help will be appreciated.
And What is the current status of zone proposal? Thanks!
The following code
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 The nativePromise.then will be executed after end, I don't understand why, any help will be appreciated.
And What is the current status of
zone proposal
? Thanks!