Thursday, November 16, 2017

loop through the properties on a JSON object in JavaScript

I stole this from here. I can't find my previous blog post on this topic.

var obj = {
   name: "Simon",
   age: "20",
   clothing: {
      style: "simple",
      hipster: false
   }
}
 
for(var propt in obj){
   alert(propt + ': ' + obj[propt]);
}

No comments:

Post a Comment