Skip to content

Commit cdfda79

Browse files
committed
fixed about reflection
1 parent cd54550 commit cdfda79

File tree

1 file changed

+22
-8
lines changed

1 file changed

+22
-8
lines changed

topics/about_reflection.js

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,22 +20,36 @@ test("property enumeration", function() {
2020
});
2121

2222
test("hasOwnProperty", function() {
23-
// hasOwnProperty returns true if the parameter is a property directly on the object,
24-
// but not if it is a property accessible via the prototype chain.
23+
24+
var A = function() {
25+
this.aprop = "A";
26+
};
27+
28+
var B = function() {
29+
this.bprop = "B";
30+
};
31+
32+
B.prototype = new A();
33+
34+
var b = new B();
35+
2536
var keys = [];
26-
var fruits = ['apple', 'orange'];
27-
for(propertyName in fruits) {
37+
for (propertyName in b) {
2838
keys.push(propertyName);
2939
}
30-
ok(keys.equalTo(['__', '__', '__']), 'what are the properties of the array?');
40+
equals(keys.length, __, 'how many elements are in the keys array?');
41+
ok(keys.equalTo([__, __]), 'what are the properties of the array?');
3142

43+
// hasOwnProperty returns true if the parameter is a property directly on the object,
44+
// but not if it is a property accessible via the prototype chain.
3245
var ownKeys = [];
33-
for(propertyName in fruits) {
34-
if (fruits.hasOwnProperty(propertyName)) {
46+
for(propertyName in b) {
47+
if (b.hasOwnProperty(propertyName)) {
3548
ownKeys.push(propertyName);
3649
}
3750
}
38-
ok(ownKeys.equalTo(['__', '__']), 'what are the own properties of the array?');
51+
equals(ownKeys.length, __, 'how many elements are in the ownKeys array?');
52+
ok(ownKeys.equalTo([__, __]), 'what are the own properties of the array?');
3953
});
4054

4155
test("eval", function() {

0 commit comments

Comments
 (0)