Example of how to use Number in Typescript (#20802)
* Example of how to use Number in Typescript * updated with changes suggested in review * updated indent in code block * updated based on @itaisteinherz suggestions
This commit is contained in:
committed by
Christopher McCormack
parent
cf44c7246d
commit
d3d6d57618
@ -13,3 +13,21 @@ let hex: number = 0xf00d;
|
||||
let binary: number = 0b0110;
|
||||
let octal: number = 0o531;
|
||||
```
|
||||
|
||||
Example of Number type usage in TypeScript:
|
||||
|
||||
```typescript
|
||||
class Employee extends Person {
|
||||
age: Number;
|
||||
constructor(age: Number){
|
||||
// Calls constructor of Person
|
||||
super();
|
||||
this.age = age;
|
||||
}
|
||||
|
||||
getAge(): Number {
|
||||
return this.age;
|
||||
}
|
||||
}
|
||||
|
||||
```
|
||||
|
Reference in New Issue
Block a user