en.javascript.info/1-js/9-object-inheritance/16-instanceof/2-instanceof-result/task.md
Ilya Kantor d4c714cbe1 work
2016-08-05 16:53:08 +03:00

25 lines
559 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

importance: 5
---
# Что выведет instanceof?
В коде ниже создаётся простейшая иерархия классов: `Animal -> Rabbit`.
Что выведет [instanceof](/instanceof)?
Распознает ли он `rabbit` как `Animal`, `Rabbit` и к тому же `Object`?
```js
function Animal() {}
function Rabbit() {}
Rabbit.prototype = Object.create(Animal.prototype);
var rabbit = new Rabbit();
alert( rabbit instanceof Rabbit );
alert( rabbit instanceof Animal );
alert( rabbit instanceof Object );
```