Answers for "take just keys of object typescript"

0

typescript object get value by key

myObj = {
  policy: {
    index: 1,
    page: "/policy"
  },
  purchase: {
    index: 2,
    page: "/purchase"
  }
}

// get value on key
Object.keys(myObj).forEach(key => {
    if (myObj[key].index === 2) {
        console.log("Found.");
    }
});

// If you want to stop the search when one was found
Object.keys(myObj).some(key => myObj[key].index === 2);
Posted by: Guest on September-15-2021
1

typescript use object keys as index

{ [key in keyof IUser]: boolean }
Posted by: Guest on May-26-2021

Code answers related to "take just keys of object typescript"

Code answers related to "TypeScript"

Browse Popular Code Answers by Language