function getLength<T extends { length: number }>(x: T): number { return x.length }
getLength([1, 2, 3]) // β 3
getLength('hello') // β 5A generic constraint T extends { length: number } allows the function to work on any 'lengthable'.
T extends { length: number } is a constraint β it allows any type that has a length property (arrays, strings, etc.).
Challenge: Implement getLength<T extends { length: number }>(x: T): number.
getLength([1, 2, 3]) // β 3
getLength('hello') // β 5