Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR TYPESCRIPT

Typescript Basic Generics

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


let fun = identity<string>("hello");
console.log(fun);   

/*T is shorthand for Type, meaning "you can specify the data type later"*/
Source by blog.openreplay.com #
 
PREVIOUS NEXT
Tagged: #Typescript #Basic #Generics
ADD COMMENT
Topic
Name
1+4 =