How to get the key of a key/value JavaScript object
Object.keys (obj).forEach ( function (key) { console.log (obj [key]) // baz }) Share Follow edited May 16, 2020 at 10:12 answered Jun 20, 2018 at 5:51 Mustkeem K 7,790 2 30 42 You may get TypeError if you expect a key to be a number. Because keys are always strings. – Green May 13, 2020 at 18:02 @Green, Why would you expect a key to be a number ?