How to declare and deal with float type in typescript?
There is no float
type in Typescript. All numbers are from the type number
.
If you want to cast an string
as number you can simply do it with the +
operator. Example:
myNumberString: string = "25";
myNumber: number = +myNumberString;
A cleaner look is to do
myNumber: number = Number(myNumberString);