TypeScript Basic Types Flashcards
How many basic types does TypeScript have?
As of version 3.3, it has 11 basic types.
What are the basic TypeScript types?
Boolean
Number
String
Array
Tuple
Enum
Any
Void
Null and Undefined
Never
Object
Tell me about the Boolean type as used in TypeScript…
The most basic datatype is the simple true/false value, which JavaScript & TypeScript call a boolean value.
Tell me about the Number type as used in TypeScript…
As in JavaScript, all numbers in TypeSctipt ate floating point values, These floating point numbers get the type “number”.
In addition to hexadecimal and decimal literals, TypeScript also supports binary and octal literals introduced in ECMAScript 2015.
Tell me about the String type as used in TypeScript…
As in other languages, TypeScript uses the type “string” to refer to textual datatypes. Just like JavaScript, TypeScript also uses double quotes or single quotes to surround string data.
Template strings are also usable in TypeScript ie using the backtick/backquote, embedded expressions and multiple lines (as per JavaScript).
Tell me about the Array type as used in TypeScript…
Like JavaScript, TypeScript allows you to work with arrays of values.
Array types can be written in two ways:
- let list: number[] = [1, 2, 3];
OR
- let list: Array<number> = [1, 2, 3];</number>