Question about JSON?
- by Alex
Hi all,
I have a fairly simple question: In Javascript how can I return the boolean (if its found in the JSON) rather than the actual value?
Example:
var myJSON = {
"foo" : "bar",
"bar" : "foo"
};
var keyToLookFor = "foo";
var found = myJSON[keyToLookFor];
if (found) {
// I know I can test if the string exists in the if
}
// but is there a way I could just return something like:
return found;
// instead of testing found in the if statement and then returning true?