Test 47: About Reflection (topics/about_reflection.js): hasOwnProperty
davidmatas opened this issue · 5 comments
Hi!
I have a problem with first part of test 47. The solution of ok(keys.equalTo(['__', '__', '__']), 'what are the properties of the array?');
should not be ['0', '1']
? Why three elements in the array?
Thanks
The for... in statement enumerates the 'equalTo' property from the array's prototype. That is the third element. The next example shows the use of hasOwnProperty to restrict for... in to the non-prototype properties.
mmm, sorry I don't understand it. If I run the example, keys
will be an array with only two elements ['0', '1']
. Exactly like the next example.
The code in the koans is actually http://jsfiddle.net/MgVnK/
However, I agree that this example is not sufficiently clear. I will improve it when I get some time. Thanks for reporting.
@davidmatas I had the same issue - here's my SO question which got some answers that sufficiently explained it for me: http://stackoverflow.com/questions/9322459/having-trouble-understanding-a-reflection-test-in-javascript-koans
I'm going to update this topic with tests based on: