I'm basically checking if certain indicators exist in a Javascript Object and if they exist, I want to return their value. Here's how I'm trying to do it:
public haveInIndicators(indicator: any): boolean {
if(indicator in this.existingIndicators) { # this condition returns true
return this.existingIndicators.indicator;
}
}
this.existingIndicators
is a variable defined somewhere else, but a console.log on it returns:
currency: true
__proto__: Object
A console.log on the passed indicator returns currency
. However, this.existingIndicators.indicator
returns undefined
.
How can I check if the passed argument does exist as a JSON key and return its value if it indeed exists?