![]() |
The keyof operator is a TypeScript type operator that takes an object type and returns a string or numeric literal union type of its keys. In simpler terms, it allows you to get a list of the keys of a given object type as a type itself. Syntax:type User = { Example 1: This example illustrates the basic usage of the keyof operator.
Output: GFG Example 2: keyof can also be used in more advanced scenarios, such as when working with mapped types. Mapped types allow you to create new types by transforming existing ones.
Output: GFG |
Reffered: https://www.geeksforgeeks.org
TypeScript |
Related |
---|
![]() |
![]() |
![]() |
![]() |
![]() |
Type: | Geek |
Category: | Coding |
Sub Category: | Tutorial |
Uploaded by: | Admin |
Views: | 19 |