aboutsummaryrefslogtreecommitdiff
path: root/files/uk/web/javascript/reference/global_objects/string/endswith
diff options
context:
space:
mode:
authorPeter Bengtsson <mail@peterbe.com>2020-12-08 14:43:23 -0500
committerPeter Bengtsson <mail@peterbe.com>2020-12-08 14:43:23 -0500
commit218934fa2ed1c702a6d3923d2aa2cc6b43c48684 (patch)
treea9ef8ac1e1b8fe4207b6d64d3841bfb8990b6fd0 /files/uk/web/javascript/reference/global_objects/string/endswith
parent074785cea106179cb3305637055ab0a009ca74f2 (diff)
downloadtranslated-content-218934fa2ed1c702a6d3923d2aa2cc6b43c48684.tar.gz
translated-content-218934fa2ed1c702a6d3923d2aa2cc6b43c48684.tar.bz2
translated-content-218934fa2ed1c702a6d3923d2aa2cc6b43c48684.zip
initial commit
Diffstat (limited to 'files/uk/web/javascript/reference/global_objects/string/endswith')
-rw-r--r--files/uk/web/javascript/reference/global_objects/string/endswith/index.html90
1 files changed, 90 insertions, 0 deletions
diff --git a/files/uk/web/javascript/reference/global_objects/string/endswith/index.html b/files/uk/web/javascript/reference/global_objects/string/endswith/index.html
new file mode 100644
index 0000000000..e387abf56c
--- /dev/null
+++ b/files/uk/web/javascript/reference/global_objects/string/endswith/index.html
@@ -0,0 +1,90 @@
+---
+title: String.prototype.endsWith()
+slug: Web/JavaScript/Reference/Global_Objects/String/endsWith
+tags:
+ - JavaScript
+ - String
+ - метод
+translation_of: Web/JavaScript/Reference/Global_Objects/String/endsWith
+---
+<div>{{JSRef}}</div>
+
+<p><span class="seoSummary">Метод <strong><code>endsWith()</code></strong> визначає, чи завершується рядок символами вказаного рядка, повертаючи, відповідно, <code>true</code> чи <code>false</code>.</span></p>
+
+<div>{{EmbedInteractiveExample("pages/js/string-endswith.html")}}</div>
+
+
+
+<h2 id="Синтаксис">Синтаксис</h2>
+
+<pre class="syntaxbox"><var>str</var>.endsWith(<var>searchString</var>[, <var>length</var>])</pre>
+
+<h3 id="Параметри">Параметри</h3>
+
+<dl>
+ <dt><code><var>searchString</var></code></dt>
+ <dd>Символи, які шукатимуться в кінці рядка <code><var>str</var></code>.</dd>
+ <dt><code><var>length</var></code> {{optional_inline}}</dt>
+ <dd>Якщо наданий, використовується як довжина <code><var>str</var></code>. За замовчуванням дорівнює <code><var>str</var>.length</code>.</dd>
+</dl>
+
+<h3 id="Значення_що_повертається">Значення, що повертається</h3>
+
+<p><strong><code>true</code></strong>, якщо надані символи знайдені в кінці рядка; інакше, <strong><code>false</code></strong>.</p>
+
+<h2 id="Опис">Опис</h2>
+
+<p>Цей метод дозволяє визначити, чи завершується рядок іншим рядком. Цей метод чутливий до регістру.</p>
+
+<h2 id="Приклади">Приклади</h2>
+
+<h3 id="Використання_endsWith">Використання <code>endsWith()</code></h3>
+
+<pre class="brush: js">let str = 'Питання в тому: бути чи не бути.'
+
+console.log(str.endsWith('бути.')) // true
+console.log(str.endsWith('Питання')) // false
+console.log(str.endsWith('Питання', 7)) // true
+</pre>
+
+<h2 id="Поліфіл">Поліфіл</h2>
+
+<p>Цей метод був доданий до специфікації ECMAScript 6 та може поки не бути доступним в усіх реалізаціях JavaScript. Однак, ви можете створити поліфіл <code>String.prototype.endsWith()</code> за допомогою наступного коду:</p>
+
+<pre class="brush: js">if (!String.prototype.endsWith) {
+ String.prototype.endsWith = function(search, this_len) {
+ if (this_len === undefined || this_len &gt; this.length) {
+ this_len = this.length;
+ }
+ return this.substring(this_len - search.length, this_len) === search;
+ };
+}
+</pre>
+
+<h2 id="Специфікації">Специфікації</h2>
+
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <th scope="col">Специфікація</th>
+ </tr>
+ <tr>
+ <td>{{SpecName('ESDraft', '#sec-string.prototype.endswith', 'String.prototype.endsWith')}}</td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="Сумісність_з_веб-переглядачами">Сумісність з веб-переглядачами</h2>
+
+<p class="hidden">The compatibility table in 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>
+
+<p>{{Compat("javascript.builtins.String.endsWith")}}</p>
+
+<h2 id="Див._також">Див. також</h2>
+
+<ul>
+ <li>{{jsxref("String.prototype.startsWith()")}}</li>
+ <li>{{jsxref("String.prototype.includes()")}}</li>
+ <li>{{jsxref("String.prototype.indexOf()")}}</li>
+ <li>{{jsxref("String.prototype.lastIndexOf()")}}</li>
+</ul>