Skip to content

Commit 1546101

Browse files
committed
Passing the wrong object to hasOwnProperty method.
1 parent a2d2b63 commit 1546101

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

doc/en/object/hasownproperty.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,26 +5,26 @@ on its [prototype chain](#object.prototype), it is necessary to use the
55
`hasOwnProperty` method which all objects inherit from `Object.prototype`.
66

77
> **Note:** It is **not** enough to check whether a property is `undefined`. The
8-
> property might very well exist, but its value just happens to be set to
8+
> property might very well exist, but its value just happens to be set to
99
> `undefined`.
1010
11-
`hasOwnProperty` is the only thing in JavaScript which deals with properties and
11+
`hasOwnProperty` is the only thing in JavaScript which deals with properties and
1212
does **not** traverse the prototype chain.
1313

1414
// Poisoning Object.prototype
15-
Object.prototype.bar = 1;
15+
Object.prototype.bar = 1;
1616
var foo = {goo: undefined};
17-
17+
1818
foo.bar; // 1
1919
'bar' in foo; // true
2020

2121
foo.hasOwnProperty('bar'); // false
2222
foo.hasOwnProperty('goo'); // true
2323

24-
Only `hasOwnProperty` will give the correct and expected result; this is
25-
essential when iterating over the properties of any object. There is **no** other
26-
way to exclude properties that are not defined on the object itself, but
27-
somewhere on its prototype chain.
24+
Only `hasOwnProperty` will give the correct and expected result; this is
25+
essential when iterating over the properties of any object. There is **no** other
26+
way to exclude properties that are not defined on the object itself, but
27+
somewhere on its prototype chain.
2828

2929
### `hasOwnProperty` as a Property
3030

@@ -45,7 +45,7 @@ necessary to use an *external* `hasOwnProperty` to get correct results.
4545
({}).hasOwnProperty.call(foo, 'bar'); // true
4646

4747
// It's also possible to use the hasOwnProperty property from the Object property for this purpose
48-
Object.prototype.hasOwnProperty.call(obj, 'bar'); // true
48+
Object.prototype.hasOwnProperty.call(foo, 'bar'); // true
4949

5050

5151
### In Conclusion

0 commit comments

Comments
 (0)