Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR TYPESCRIPT

object add property typescript

Copy 
1interface User {
2  id: number;
3  name: string;
4  domain?: string;
5  age?: number;
6  isActive?: boolean;
7}
8
9let user: User = {
10  id: 1,
11  name: "infinitbility",
12};
13
14// Add element for dynamic key
15user["isActive"] = true;
16console.log("user", user);
Source by infinitbility.com #
 
PREVIOUS NEXT
Tagged: #object #add #property #typescript
ADD COMMENT
Topic
Name
5+6 =