Given for..of example needs some explanation, not self-explaining

NEW
Assigned to

Status

P5
normal
2 years ago
a year ago

People

(Reporter: nachtigall, Assigned: mozilla)

Tracking

Details

(URL)

(Reporter)

Description

2 years ago
:: Developer Documentation Request

      Request Type: Correction
     Gecko Version: 51 Branch
 Technical Contact: fscholz@mozilla.com

:: Details

Since there's no other way to leave feedback (you should really have something like a small ThumbsUp/ThumbsDown feedback form on each MDN page), I'll leave this here:

I do not find the example given at https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for...of#Difference_between_for...of_and_for...in self-explaining. In particular, in line 8 why does it log 
// logs 0, 1, 2, "foo", "arrCustom", "objCustom" 
and not
// logs 0, 1, 2, "hello", "arrCustom"
?

Why "objCustom" if it is an array? Why "foo" if it is "hello"?
Component: General → JavaScript
(Assignee)

Comment 1

a year ago
I think that I could make a few changes that would make the doc section better:

- Add a short introductory sentence describing how are for...of and for...in similar and how they differ while keeping the two paragraphs describing what they do almost intact.
- Add an explanation to every couple of lines of the example (lines 1-2, 4-5, 7-9, 11-15, 17-19).
- Add several links to other docs - for example for enumerable properties, hasOwnProperty etc.

Do you agree? Can I work on this?
Yes, feel free to improve the MDN wiki pages! Thank you!
Assignee: nobody → mozilla
(Assignee)

Comment 3

a year ago
I've made the necessary changes. I wrote the introduction little differently, other changes are as described in my last comment. 

Are the changes for the better? Feel free to tell me about any mistakes I've made or changes I should do. It's my first contribution so I'm not that sure if everything was done correctly.
You need to log in before you can comment on or make changes to this bug.