Posts

Showing posts from January, 2020

Data types in Typescript

Data types in Typescript: Syntax to declare a variable :   var/let varName : datatype;  we can also assign value at the time of variable declaration.(see below examples). We can define datatype of a variable, from below mentioned types: Number : // Number let   num : number ; console . log ( num ); // undefined num = 33 ; console . log ( num );  //33 console . log ( "What if, we will try to assign any other type of value to num" ); // num="sss"; // Error :Type '"sss"' is not assignable to type 'number'. // console.log(num); Boolean: let   isBoolean :   boolean = true ;  // isBoolean will accept only 'true' and 'false' values. console . log ( isBoolean ); String: all java script code is valid Typescript code so, we can also use java scrip...