aboutsummaryrefslogtreecommitdiff
path: root/files/ru/web/javascript/reference/global_objects/symbol/hasinstance
diff options
context:
space:
mode:
authorPeter Bengtsson <mail@peterbe.com>2020-12-08 14:42:52 -0500
committerPeter Bengtsson <mail@peterbe.com>2020-12-08 14:42:52 -0500
commit074785cea106179cb3305637055ab0a009ca74f2 (patch)
treee6ae371cccd642aa2b67f39752a2cdf1fd4eb040 /files/ru/web/javascript/reference/global_objects/symbol/hasinstance
parentda78a9e329e272dedb2400b79a3bdeebff387d47 (diff)
downloadtranslated-content-074785cea106179cb3305637055ab0a009ca74f2.tar.gz
translated-content-074785cea106179cb3305637055ab0a009ca74f2.tar.bz2
translated-content-074785cea106179cb3305637055ab0a009ca74f2.zip
initial commit
Diffstat (limited to 'files/ru/web/javascript/reference/global_objects/symbol/hasinstance')
-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>