Thursday, April 6, 2017

cast a string to a number in TypeScript

doSomething(setting: string) {
   let shouldGoForward: boolean = false;
   let price: number = Number(setting);
   if (price || price === 0) {
      shouldGoForward = true;
   }

 
 

Maybe you can imagine what comes downstream based on the shouldGoForward flag.

No comments:

Post a Comment