Skip to content
RED SAGSkills
medium10 pts · first answer countsjavascripttypescriptgenerics

A typed getter with keyof

What is the type of v?

function get<T, K extends keyof T>(obj: T, key: K): T[K] {
  return obj[key]
}
const v = get({ name: "Ali", age: 30 }, "age")
Choose one answer

Discussion 0

Join free to post in the discussion.

Related questions