Loading

TypeScript

Data types in TypeScript. The Complete TypeScript Developer Course 2023 [Videos].

Whenever a variable is created, the intention is to assign some value to that variable but what type of value can be assigned to that variable is dependent upon the datatype of that Variable. In typeScript, type System represents different types of datatypes which are supported by TypeScript. The data type classification is as given below:

Built-in Datatypes: TypeScript has some pre-defined data-types-

Built-in Data TypekeywordDescription
NumbernumberIt is used to represent both Integer as well as Floating-Point numbers
BooleanbooleanRepresents true and false
StringstringIt is used to represent a sequence of characters
VoidvoidGenerally used on function return-types
NullnullIt is used when an object does not have any value
UndefinedundefinedDenotes value given to uninitialized variableAnyanyIf variable is declared with any data-type then any type of value can be assigned to that variable

Examples:


let a: null = null;

let b: number = 123;

let c: number = 123.456;

let d: string = "Geeks";

let e: undefined = undefined;

let f: boolean = true;

let g: number = 0b111001; // Binary

let h: number = 0o436; // Octal

let i: number = 0xadf0d; // Hexa-Decimal

User-defined Data Types: Apart from built-in data types, user can also define its own data type. User-defined types include Enumerations (enums), classes, interfaces, arrays, and tuple.

See All

Comments (171 Comments)

Submit Your Comment

See All Posts

Related Posts

TypeScript / Blog

Difference between TypeScript and JavaScript

When JavaScript was developed the JavaScript development team introduced JavaScript as a client-side programming language. But when people were using JavaScript then developers get to know that JavaScript can be used as a server-side programming language also. But When JavaScript was growing then the code of JavaScript became complex and heavy.
19-jan-2022 /33 /171

TypeScript / Blog

What is the difference between interface and type in TypeScript ?

Both the methods Type and the Interface are used to describe the structure of the objects in TypeScript. But holds some specific features that will be helpful according to the situation, choosing between them and totally depends on the developer.
/33 /171

TypeScript / Blog

What is the Function type in TypeScript ?

TypeScript is a JavaScript-based programming language with a typed syntax. It provides improved tools of any size. It adds extra syntax to JavaScript. This helps in facilitating a stronger interaction between you and your editor. It also helps in catching the mistakes well in advance.
19-jan-2022 /33 /171