You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 876498f
Browse filesBrowse the repository at this point in the historyBrowse files
The `instanceof` operator compares the constructors of its two operands. It is
4
-
only useful when comparing custom made objects. Used on built-in types, it is
5
-
nearly as useless as the [typeof operator](#types.typeof).
3
+
Оператор `instanceof` сравнивает конструкторы двух операндов. Это полезно только когда сравниваются пользовательские объекты. Использование на встроенных типах почти так же бесполезно, как оператор [оператор typeof](#types.typeof).
6
4
7
-
### Comparing custom objects
5
+
### Сравнение пользовательских объектов
8
6
9
7
function Foo() {}
10
8
function Bar() {}
@@ -13,26 +11,22 @@ nearly as useless as the [typeof operator](#types.typeof).
13
11
new Bar() instanceof Bar; // true
14
12
new Bar() instanceof Foo; // true
15
13
16
-
// This just sets Bar.prototype to the function object Foo
17
-
// But not to an actual instance of Foo
14
+
// Всего лишь присваиваем Bar.prototype объект функции Foo,
One important thing to note here is, that `instanceof` does not work on objects
30
-
that origin from different JavaScript contexts (e.g. different documents
31
-
in a web browser), since their constructors will not be the exact same object.
27
+
Здесь надо отметить одну важную вещь: `instanceof` не работает на объектах, которые происходят из разных контекстов JavaScript (например, из различных документы в web-браузере), так как их конструкторы не будут конструкторами *тех самых* объектов.
32
28
33
-
### In conclusion
29
+
### Заключение
34
30
35
-
The `instanceof` operator should **only** be used when dealing with custom made
36
-
objects that origin from the same JavaScript context. Just like the
37
-
[`typeof`](#types.typeof) operator, every other use of it should be **avoided**.
31
+
Оператор instanceof должен использоваться **только** при обращении к пользовательским объектам, происходящим из одного контекста JavaScript. Так же, как и в случае оператора `typeof`, любое другое использование необходимо **избегать**.
0 commit comments