51. Create Generic Function with Keyof Constraint in the TypeScript.

preview_player
Показать описание
Hi Friends
In this video, we will see how to use keyof constraint in the typescript language.

If you like this video, please subscribe to my channel.
Рекомендации по теме
Комментарии
Автор

Great explanation sir. I have a doubt that why we used extend... Why we cannot do U keyof T ? and T: object

bobbysadhwani
Автор

Hello @leela, Thanks for the video
"extractKeyFormObject" in this function what could be a return type, i tried with string, its throwing error.
can you please tell :)
function extractKeyFormObject<T extends object, B extends keyof T>(obj : T, key : B):string{
return obj[key];
}
extractKeyFormObject({name:"bala", age:20}, "name");

balasubramani
join shbcf.ru