Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Java by (13.1k points)
Can anyone help me how I can able to loop through all the members including values that are objects?

1 Answer

0 votes
by (26.7k points)

You can use the following code to achieve that:

for (var key in validation_messages) {

    // skip loop if the property is from prototype

    if (!validation_messages.hasOwnProperty(key)) continue;

    var obj = validation_messages[key];

    for (var prop in obj) {

        // skip loop if the property is from prototype

        if (!obj.hasOwnProperty(prop)) continue;

        // your code

        alert(prop + " = " + obj[prop]);

    }

}

I hope this will help.

Want to become a Java Expert? Join Java Course now!!

Related questions

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

Browse Categories

...