Q1. Explain generics and give a realistic use case.
Generics let you write code that works over many types while preserving the relationship between input and output types. ```ts function first(items: T[]): T | undefined {...
Technical Question Bank · Peer-Reviewed
Search and filter frequently asked interview questions across technical, programming, and behavioral domains. Tailor your interview preparation by difficulty for freshers or experienced developers (6 available).
Generics let you write code that works over many types while preserving the relationship between input and output types. ```ts function first(items: T[]): T | undefined {...
Lifetimes are generic annotations that describe how long references remain valid, so the compiler can prove they never dangle. Most lifetimes are elided and invisible in ...
Generics let you write type-safe, reusable code without boxing or casts. The type parameter is resolved at compile time, and the JIT specialises for value types while sha...
A trait defines shared behaviour: a set of method signatures a type can implement. Implementations can be written for types you did not define, as long as you own the tra...
Variance describes how generic types relate when their type arguments are related. `out T` (covariant) means `Producer` can be used where `Producer` is expected. `in T` (...
Generics in TypeScript enable you to create reusable code that can work with different data types. They act as placeholders for types and provide flexibility without sacr...
HireXTech uses essential storage to remember your study preferences and third-party advertising cookies via Google AdSense in compliance with GDPR. You can choose to enable essential cookies only or accept all cookies. Read our Privacy Policy.