Negating a Promise tests the Promise object, not its eventual value. Resolve the boolean first, then apply the negation.
The odd counterpart of an asynchronous evenness check is !(await isEven(n)). Writing !isEven(n) negates the returned Promise object immediately. It does not wait for the eventual boolean. This independent JavaScript explanation uses the is-jodd experiment as a concrete example; it is not official TypeSafe documentation.
A Promise is an object, and ordinary objects are truthy under JavaScript’s boolean conversion rules. Negating one therefore produces false, regardless of whether it later resolves to true or false. ECMAScript boolean conversion
Reproduce the mistake without an API call
A tiny local function demonstrates the behavior without credentials, network access, or either npm package:
async function exampleIsEven(n) {
return n % 2 === 0;
}
console.log(!exampleIsEven(3)); // false
console.log(!(await exampleIsEven(3))); // true
console.log(!(await exampleIsEven(4))); // false
The first line is wrong for oddness because it operates on the container. The other two lines operate on the resolved value. Parentheses make the intended order visible to someone scanning the code and help prevent a refactor from moving the negation to the wrong place.
Another readable version names the intermediate result:
const even = await exampleIsEven(3);
const odd = !even;
That extra variable is useful when logging a value or stepping through a debugger. Saving a character is not worth obscuring whether code is examining a Promise or its result.
Await does not convert rejection into false
An async function can reject instead of resolving. Awaiting it surfaces that failure to the surrounding async control flow. The negation does not magically produce an answer in that case. Use explicit error handling when the function can fail, and keep the error state distinct from a resolved boolean.
This matters for is-jeven and is-jodd because both contact a remote service. Missing credentials, an unsuccessful response, or cancellation can prevent either call from returning an answer. The errors article explains why a catch-all false would misrepresent the outcome.
Compare complete operations
Our live benchmark used the correctly awaited negation as its baseline. It did not compare is-jodd against a broken immediate Promise check. The result still did not establish a latency advantage for the direct oddness wrapper. Removing ! is not a supported explanation for faster API calls.
Read is-jodd versus is-jeven for the actual measurements. Use the calculator when you need parity rather than an async example. The local demonstration above requires neither joke package; is-jodd itself remains subject to its restrictive custom license, including $1 trillion and written permission unless separate terms are granted.