How to do find index==2
in TypeScript?
myObj = {
policy : {
index: 1,
page : "/summer"
},
purchase : {
index: 2,
page : "/sun"
}
}
E.g.
for (var key in myObj) {
if (myObj.hasOwnProperty(key)) {
if (myObj[key].index === 2)
console.log("Found.");
}
}
How to do this in JS or TS more efficiently?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With