Object Keys
EasyType the function so that key can only be a key of obj.
const getObjField = (obj, key) => {
return obj[key]
}TypeScript•UTF-8
Run your code to see results.
Click the Run button above
Object Keys
EasyType the function so that key can only be a key of obj.
const getObjField = (obj, key) => {
return obj[key]
}Examples:
Input 1: getObjField({ name: "Nik" }, "name")
Output 1: string
Input 2: getObjField({ age: 25 }, "age")
Output 2: number
Output
Run your code to see results.