JavaScript & TypeScript

Generics

/dʒɪˈnerɪks/

Definition

A TypeScript feature allowing functions, classes, and interfaces to work with multiple types while preserving type information.

Example in context

"function identity<T>(arg: T): T returns the same type as input — call it with a string, get a string back."

Related terms

Practice this term

Master Generics in context by working through exercises in the JavaScript & TypeScript module. You'll see the term used in real engineering scenarios with multiple-choice, fill-in-the-blank, and matching drills.