In this blog post, we will explore how objects and properties are typed statically in TypeScript.
One way of understanding types is as sets of values. Sometimes there are two levels of values:
In this blog post, we examine how we can add special values to base-level types.
This blog post answers the following two questions:
In this blog post, we examine a pattern for implementing enums in JavaScript that is based on classes. We’ll also take a look at Enumify, a library that helps with the enum pattern.
/g
, /y
, and .lastIndex
In this blog post, we examine how the RegExp flags /g
and /y
work and how they depend on the RegExp property .lastIndex
. We’ll also discover an interesting use case for .lastIndex
that you may not have considered yet.
Intl.PluralRules
In this blog post, we’ll explore a very simple way to handle reporting of numbers of items that respects grammatical number (in English: singular and plural).
Update 2020-04-02: Today, the ES2020 candidate was released, with the final feature set of that version. This blog post describes what’s new.
The ECMAScript proposal “RegExp match indices” (by Ron Buckton) adds more information to regular expression match objects (as returned by RegExp.prototype.exec()
and other methods): They now record for each captured group where it starts and where it ends. Read on for more information.
String.prototype.replaceAll
The normal string method .replace()
only lets you replace one occurrence if you search for string (and not a regular expression with the flag /g
). The proposal “String.prototype.replaceAll
” (by Peter Marshall, Jakob Gruber, Mathias Bynens) fixes that.
Promise.any()
The ECMAScript proposal “Promise.any()” (by Mathias Bynens, Kevin Gibbons, and Sergey Rubanov) introduces a new Promise combinator for JavaScript. This blog post explains how it works.