TypeScript Code Completion Medium +20 XP
Generic Function
Complete the generic function.
TypeScriptFill in the blank
function identity<___>(arg: T): T {
return arg;
}Type the missing code
Show answer and explanation
Answer: T
Generics use type parameters (conventionally T) to create reusable typed functions.
Hint: What letter conventionally represents a generic type?
What this challenge tests
Code Completion in TypeScript: generics, functions.