aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/javascript/reference/global_objects/array/lastindexof
diff options
context:
space:
mode:
authort7yang <t7yang@gmail.com>2022-01-10 08:38:07 +0800
committerIrvin <irvinfly@gmail.com>2022-02-16 02:35:54 +0800
commitc40612041809fe289aba58aefa170bbe784aba1f (patch)
tree8ca89b071d04afcf7abd6d9a04d0765a041d9c8a /files/zh-cn/web/javascript/reference/global_objects/array/lastindexof
parent12a899ab8540bc84f56a0dc6491be80a48499d49 (diff)
downloadtranslated-content-c40612041809fe289aba58aefa170bbe784aba1f.tar.gz
translated-content-c40612041809fe289aba58aefa170bbe784aba1f.tar.bz2
translated-content-c40612041809fe289aba58aefa170bbe784aba1f.zip
remove name attribute for zh-CN
Diffstat (limited to 'files/zh-cn/web/javascript/reference/global_objects/array/lastindexof')
-rw-r--r--files/zh-cn/web/javascript/reference/global_objects/array/lastindexof/index.html18
1 files changed, 9 insertions, 9 deletions
diff --git a/files/zh-cn/web/javascript/reference/global_objects/array/lastindexof/index.html b/files/zh-cn/web/javascript/reference/global_objects/array/lastindexof/index.html
index 51cf89a71f..8d3c63aab0 100644
--- a/files/zh-cn/web/javascript/reference/global_objects/array/lastindexof/index.html
+++ b/files/zh-cn/web/javascript/reference/global_objects/array/lastindexof/index.html
@@ -5,17 +5,17 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Array/lastIndexOf
---
<div>{{JSRef("Global_Objects", "Array")}}</div>
-<h2 id="Summary" name="Summary">概述</h2>
+<h2 id="Summary">概述</h2>
<p><code><strong>lastIndexOf()</strong></code> 方法返回指定元素(也即有效的 JavaScript 值或变量)在数组中的最后一个的索引,如果不存在则返回 -1。从数组的后面向前查找,从 <code>fromIndex</code> 处开始。</p>
<div>{{EmbedInteractiveExample("pages/js/array-lastindexof.html")}}</div>
-<h2 id="Syntax" name="Syntax">语法</h2>
+<h2 id="Syntax">语法</h2>
<pre><var>arr</var>.lastIndexOf(<var>searchElement[</var>, <var>fromIndex]</var>)</pre>
-<h3 id="Parameters" name="Parameters">参数</h3>
+<h3 id="Parameters">参数</h3>
<dl>
<dt><code>searchElement</code></dt>
@@ -29,13 +29,13 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Array/lastIndexOf
</dd>
</dl>
-<h2 id="Description" name="Description">描述</h2>
+<h2 id="Description">描述</h2>
<p><code>lastIndexOf</code> 使用<a href="https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Operators/Comparison_Operators#Using_the_Equality_Operators">严格相等</a>(strict equality,即 ===)比较 <code>searchElement</code> 和数组中的元素。</p>
-<h2 id="Examples" name="Examples">示例</h2>
+<h2 id="Examples">示例</h2>
-<h3 id="Example_Using_lastIndexOf" name="Example:_Using_lastIndexOf">例子:使用 lastIndexOf</h3>
+<h3 id="Example_Using_lastIndexOf">例子:使用 lastIndexOf</h3>
<p>下例使用 <code>lastIndexOf</code> 定位数组中的值。</p>
@@ -54,7 +54,7 @@ index = array.lastIndexOf(2, -1);
// index is 3
</pre>
-<h3 id="Example_Finding_all_the_occurrences_of_an_element" name="Example:_Finding_all_the_occurrences_of_an_element">例子:查找所有元素</h3>
+<h3 id="Example_Finding_all_the_occurrences_of_an_element">例子:查找所有元素</h3>
<p>下例使用 <code>lastIndexOf</code> 查找到一个元素在数组中所有的索引(下标),并使用 {{jsxref("Array.push", "push")}} 将所有添加到另一个数组中。</p>
@@ -80,7 +80,7 @@ console.log(indices);
<code>idx &gt; 0</code>时,才进入lastIndexOf由后往前移一位进行倒查找;如果<code>idx == 0</code>则直接设置<code>idx = -1</code>,循环<code>while (idx != -1)</code>就结束了。<br>
 </p>
-<h2 id="Compatibility" name="Compatibility">兼容旧环境(Polyfill)</h2>
+<h2 id="Compatibility">兼容旧环境(Polyfill)</h2>
<p><code>lastIndexOf</code> 在 ECMA-262 标准第 5 版被添加。因此它在不兼容该标准的浏览器中可能不被支持。你可以把下面代码添加到脚本中来使那些没有实现该方法的实现环境支持该方法。该算法是被 ECMA-262 第 5 版指定的。假定 {{jsxref("Global_Objects/Object", "Object")}}、{{jsxref("Global_Objects/TypeError", "TypeError")}}、{{jsxref("Global_Objects/Number", "Number")}}、{{jsxref("Math.floor")}}、{{jsxref("Math.abs")}},以及 {{jsxref("Math.min")}} 拥有其初始值。</p>
@@ -168,7 +168,7 @@ console.log(indices);
<p>{{Compat("javascript.builtins.Array.lastIndexOf")}}</p>
</div>
-<h2 id="See_also" name="See_also">相关链接</h2>
+<h2 id="See_also">相关链接</h2>
<ul>
<li>{{jsxref("Array.prototype.indexOf()")}}</li>