Type Narrowing Techniques in TypeScript
Type narrowing techniques can resolve the dilemma between type flexibility with union types and type certainty when processing them.
- Archive
- JavaScript
- TypeScript
- Machine Translated
Type narrowing techniques can resolve the dilemma between type flexibility with union types and type certainty when processing them.
This time we will dive deeper into the Optional Chaining operator introduced in ES2020, covering the motivation, syntax, and use-case examples.
Nullish values require special attention when working with objects. ES2020 introduced optional chaining and nullish coalescing to handle this.
Like many other programming languages, JavaScript has indicators of absence: null and undefined. What should we pay attention to about them?
Arrays in JavaScript are a fascinating thing. Arrays have many interesting and very useful prototype methods. What are they?
ES6 introduced a new concept called protocols, with its first two being: Iterable and Iterator, which we can use to power up our iteration.
When the number data type, weak typing, and primitive type coercion meet, they produce wonders. Wonders, in the sense of confusing phenomena.
Learning about destructuring assignment in JavaScript, a feature introduced by ES6, which improves readability and shortens code.
In Javascript, there are several terms that sound superficially similar: undefined, null, not defined, and undeclared. See the differences here.
> Good authors divide their books into chapters; good programmers divide their programs into modules. Linguistically, a module can be defined as a self-contained component of a system that supports the program of that system...
The use of global variables in Javascript is strongly discouraged for many reasons [1]. Two of the main reasons are the difficulty of controlling access to resources available to the entire application...