TypeScript

null & undefined in TS

Në shqip: null dhe undefined në TS

ShpjegimiSQ

Me strictNullChecks, null dhe undefined janë tipe më vete — string s'pranon null pa e shkruar string | null. Zakonisht undefined do të thotë „s'është vendosur“ dhe null „qëllimisht bosh“.

EnglishEN

With strictNullChecks, null and undefined are types of their own — string won't accept null unless you write string | null. Usually undefined means “not set” and null “intentionally empty”.

Si ta mendosh

Si dallimi mes një kutie që s'është mbushur ende dhe një kutie që e ke zbrazur qëllimisht.

Lexoje në anglisht

Like the difference between a box not filled yet and a box you emptied on purpose.

Shembull koditypescript

let mbiemri: string | null = null;
let mosha: number | undefined;

Terma të lidhur