TypeScript

Type Guard

Narrow with typeof.

💡 THINK OF IT LIKE…
▸ YOUR TURN

Write: if (typeof x === 'string') { x.toUpperCase(); }

narrow.ts
+120 XP
Tab indent · Shift+Tab outdent · ⌘/Ctrl + Enter submit · auto-pairs ( [ { " '