Skip to content

Iterating over the enumerable properties of an object #281

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed

Iterating over the enumerable properties of an object #281

wants to merge 3 commits into from

Conversation

hemanth
Copy link
Contributor

@hemanth hemanth commented Mar 1, 2013

Should go the loop section?

for(var prop in myObject) {
console.log(key);
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution :) However, this code produces an error: ReferenceError: key is not defined. Also, please make sure you're following the style guide with any code contributions -- you'll want to address the spacing in the for loop. Finally, you may want to show how to log both the key and the value.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Opps! I was testing in the console and was logging as key, then wondered key wont sound good and added prop!
Yup will send in a new P.R.

for ( var prop in myObject ) { 
  console.log("Property : "+prop+" ; value : "+myObject[prop]); 
}

@rmurphey Something like ^ seems fine?

@ajpiano
Copy link
Member

ajpiano commented Mar 14, 2013

This PR appears to be superseded by #282

@ajpiano ajpiano closed this Mar 14, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants