Search code examples
javascriptasync-awaitternary

Operator precedence between await and ternary


I tried this with Chrome console:

const foo = async () => 1;
const bar = async () => 2;
(await 1) ? foo() : bar();

The result is 1.

Can you explain this please? Isn't it suppose to return a Promise?


Solution

  • It seems the chrome console did something under the hood which is not the concern of this question. The result of the operation is as expected.

    Perhaps this is a only bug of chrome console?

    Thanks to Paulpro