1

What if I want to, with an object of arbitrary depth, see if a key occurs anywhere in it.
Take for example, this object:

let obj = {
  "heave": {
    "blah": 2,
    "foo": {
      "bar": "yes"
    }
  },
  "hoo": {
    "obj": "you were fooled",
    "number": {
      "ha": "ha"
    }
  }
};

and I want to find if it has the key bar on any level, preferably in one statement. I know I can just loop through every level, this is a "there's gotta be a better way" question.
I've looked at this question and this question, but they only answer the first level and neither question's answers work deeper.

MattDahEpic
  • 73
  • 3
  • 13

0 Answers0