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
1
2
3
4
5
export class UserProfile {age: number = 25;isAdmin: boolean = false;}
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.