TypeScript

Non-null assertion (!)

Në shqip: Pohimi „s'është null“

ShpjegimiSQ

Pikëçuditja pas një vlere (perdoruesi!.emri) i thotë TypeScript-it „jam i sigurt që s'është null ose undefined“. Është i shpejtë, por po gabove, programi rrëzohet — më mirë kontrolloje me if ose ?.

EnglishEN

An exclamation mark after a value (user!.name) tells TypeScript “I'm sure this isn't null or undefined”. It's quick, but if you're wrong the program crashes — better to check with if or ?.

Si ta mendosh

Si të kërcesh nga trampolina pa parë nëse ka ujë në pishinë.

Lexoje në anglisht

Like jumping off the diving board without checking there's water in the pool.

Shembull koditypescript

const butoni = document.querySelector("button")!;
butoni.addEventListener("click", ruaj);

Terma të lidhur