Quantcast
Channel: Iterate through object properties - Stack Overflow
Viewing all articles
Browse latest Browse all 35

Answer by Kamil Kiełczewski for Iterate through object properties

$
0
0

Check type

You can check how propt represent object propertis by

typeof propt

to discover that it's just a string (name of property). It come up with every property in the object due the way of how for-in js "build-in" loop works.

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

Viewing all articles
Browse latest Browse all 35

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>