Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR TYPESCRIPT

type in typescript


    function identity<Type>(arg: Type): Type {
      return arg;
    }


let fun = identity<string>("hello world");
console.log(fun);   
/*think of this as you can specify the type later*/
/*Directly specifying version of the above would be something like
    function identity(arg: string): string {
      return arg;
    }


let fun = identity("hello world");
console.log(fun);   

*/
Source by www.typescriptlang.org #
 
PREVIOUS NEXT
Tagged: #type #typescript
ADD COMMENT
Topic
Name
5+7 =