How to Loop through JavaScript object literal with objects as members?

Posted by ed.talmadge on Stack Overflow See other posts from Stack Overflow or by ed.talmadge
Published on 2009-05-28T16:18:14Z Indexed on 2010/05/19 21:00 UTC
Read the original article Hit count: 238

Filed under:
|

How can I loop through all members in a JavaScript object including values that are objects.

For example, how could I loop through this (accessing the "your_name" and "your_message" for each)?

var validation_messages = {
    "key_1": {
    	"your_name": "jimmy",
    	"your_msg": "hello world"
    },
    "key_2": {
    	"your_name": "billy",
    	"your_msg": "foo equals bar"
    }
}

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about object-literal