Skip to content

Commit d617a18

Browse files
committed
Clarify the code example about comparing custom objects
1 parent c610517 commit d617a18

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

doc/instanceof.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,14 @@ nearly as useless as the [typeof operator](#typeof).
88

99
function Foo() {}
1010
function Bar() {}
11-
Bar.prototype = Foo;
11+
Bar.prototype = new Foo();
1212

1313
new Bar() instanceof Bar; // true
14+
new Bar() instanceof Foo; // true
15+
16+
// This just sets Bar.prototype to the function object Foo
17+
// But not to an actual instance of Foo
18+
Bar.prototype = Foo;
1419
new Bar() instanceof Foo; // false
1520

1621
### Using `instanceof` with native types

0 commit comments

Comments
 (0)