← Back to archive

Stdle #16 · narrowing · 2026-06-22

What does this TypeScript snippet output?

A past puzzle — fully playable. 4 attempts, hints on wrong guesses.

function isNum(x: unknown): x is number {
return typeof x === "number"
}
const r = [1, "a", 2].filter(isNum)
console.log(r.length)
Narrowing
4 attempts left

Answer & explanation