wrapper object
An object created by new String, new Number or new Boolean that wraps a primitive value, and should not be used as a type.
In more detail
The capitalised String is the constructor function and its interface; the lowercase string is the primitive type. new String("a") is an object, so it compares differently and TypeScript will not assign it to string. Linters flag the capitalised names in annotations.
Related terms
- primitive type — A basic built-in type, such as a whole number or true-or-false, whose values are held directly rather than as objects.
- string — The type for text values, such as a name or an email address.
- constructor — The special method that runs when a new object is created from a class and sets up its starting data.
Taught in
- Primitive Types: String, Number, Boolean, Bigint And Symbol — Production TypeScript