问题:
How can I loop through all members in a JavaScript object including values that are objects. 如何遍历JavaScript对象中的所有成员,包括对象值。
For example, how could I loop through this (accessing the "your_name" and "your_message" for each)? 例如,如何循环浏览(分别访问“ your_name”和“ your_message”)?
var validation_messages = {
"key_1": {
"your_name": "jimmy",
"your_msg": "hello world"
},
"key_2": {
"your_name": "billy",
"your_msg": "foo equals bar"
}
}
解决方案:
参考一: https://stackoom.com/question/3rnZ/如何遍历以对象为成员的纯JavaScript对象参考二: https://oldbug.net/q/3rnZ/How-to-loop-through-a-plain-JavaScript-object-with-the-objects-as-members
来源:oschina
链接:https://my.oschina.net/u/4428122/blog/4303301