How come it Prints all property values , when only one is assinged


how come it prints all object property values when we set only one property name in var x at line 9 i.e. var x="fullName" and still it prints all value of nyc object

var nyc = {
    fullName: "New York City",
    mayor: "Bill de Blasio",
    population: 8000000,
    boroughs: 5

// write a for-in loop to print the value of nyc's properties
var x= "fullName";
for(var x in nyc){


I dont can explain it better than the Mozilla Developer Network

So read pleas this here

And you will get a Idea how a for ... in loop works


Got it.thanks for the reply.


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.