aboutsummaryrefslogtreecommitdiff
path: root/files/ru/web/javascript/reference/global_objects/symbol/hasinstance/index.html
diff options
context:
space:
mode:
Diffstat (limited to 'files/ru/web/javascript/reference/global_objects/symbol/hasinstance/index.html')
-rw-r--r--files/ru/web/javascript/reference/global_objects/symbol/hasinstance/index.html71
1 files changed, 71 insertions, 0 deletions
diff --git a/files/ru/web/javascript/reference/global_objects/symbol/hasinstance/index.html b/files/ru/web/javascript/reference/global_objects/symbol/hasinstance/index.html
new file mode 100644
index 0000000000..48c2d59173
--- /dev/null
+++ b/files/ru/web/javascript/reference/global_objects/symbol/hasinstance/index.html
@@ -0,0 +1,71 @@
+---
+title: Symbol.hasInstance
+slug: Web/JavaScript/Reference/Global_Objects/Symbol/hasInstance
+tags:
+ - JavaScript
+ - Property
+ - Symbol
+translation_of: Web/JavaScript/Reference/Global_Objects/Symbol/hasInstance
+---
+<div>{{JSRef}}</div>
+
+<p><strong><code>Symbol.hasInstance</code></strong> — известный символ, который используется для определения является ли объект экземпляром конструктора. Этот символ используется для изменения поведения оператора {{jsxref("Operators/instanceof", "instanceof")}}.</p>
+
+<div class="hidden">
+<p>The source for this interactive example is stored in a GitHub repository. If you'd like to contribute to the interactive examples project, please clone <a href="https://github.com/mdn/interactive-examples">https://github.com/mdn/interactive-examples</a> and send us a pull request.</p>
+</div>
+
+<div>{{js_property_attributes(0,0,0)}}</div>
+
+<h2 id="Примеры">Примеры</h2>
+
+<p>Поведение <code>instanceof</code> может быть изменено, например, следующим образом:</p>
+
+<pre class="brush: js">class MyArray {
+ static [Symbol.hasInstance](instance) {
+ return Array.isArray(instance);
+ }
+}
+console.log([] instanceof MyArray); // true</pre>
+
+<h2 id="Спецификации">Спецификации</h2>
+
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <th scope="col">Спецификация</th>
+ <th scope="col">Статус</th>
+ <th scope="col">Комментарий</th>
+ </tr>
+ <tr>
+ <td>{{SpecName('ES2015', '#sec-symbol.hasinstance', 'Symbol.hasInstance')}}</td>
+ <td>{{Spec2('ES2015')}}</td>
+ <td>Изначальное определение.</td>
+ </tr>
+ <tr>
+ <td>{{SpecName('ESDraft', '#sec-symbol.hasinstance', 'Symbol.hasInstance')}}</td>
+ <td>{{Spec2('ESDraft')}}</td>
+ <td> </td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="Совместимость_с_браузерами">Совместимость с браузерами</h2>
+
+<p> </p>
+
+<div class="hidden">
+<p>The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> and send us a pull request.</p>
+</div>
+
+<p>{{Compat("javascript.builtins.Symbol.hasInstance")}}</p>
+
+<p> </p>
+
+<div id="compat-desktop"> </div>
+
+<h2 id="Смотрите_также">Смотрите также</h2>
+
+<ul>
+ <li>{{jsxref("Operators/instanceof", "instanceof")}}</li>
+</ul>