0 day streak
javascript / beginner
Snippet

Basic Types in TypeScript

Angular uses TypeScript, which allows you to define data types for your variables, helping to prevent bugs by ensuring data consistency.

snippet.js
javascript
1
2
3
4
5
export class UserProfile {
age: number = 25;
isAdmin: boolean = false;
email: string = '[email protected]';
}
angular
Breakdown
1
age: number
Specifies that the variable 'age' must always hold a numeric value.
2
isAdmin: boolean
Restricts the 'isAdmin' variable to only true or false values.