Null or undefined
Like dynamic type, JavaScript allows variables to be assigned null or undefined. Unless proper validations are done every time a variable is accessed, we get to see errors such as undefined is not a function or cannot read property x of undefined. This happens because there are no specific checks in JavaScript by the language to make sure we are not accessing or assigning any variable or function as undefined or null. TypeScript, with its type declaration, reduces the probability of having such issues and, in addition to that, TypeScript has a compiler flag, strictNullChecks, which allows the compiler to flag any instance where the application is assigning any null or undefined type. The TypeScript compiler also does control ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access