From d9e9adb5f80a819fe46349bcf6d1faec734b09cd Mon Sep 17 00:00:00 2001 From: Irvin Date: Wed, 16 Feb 2022 02:07:31 +0800 Subject: remove span tag in zh-CN --- .../global_objects/array/length/index.html | 24 +++++++++++----------- 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'files/zh-cn/web/javascript/reference/global_objects/array/length') diff --git a/files/zh-cn/web/javascript/reference/global_objects/array/length/index.html b/files/zh-cn/web/javascript/reference/global_objects/array/length/index.html index 7b126495fb..8f17e9af1f 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/array/length/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/array/length/index.html @@ -82,25 +82,25 @@ function printEntries(arr) {

下面的例子中,通过数组下标遍历数组元素,并把每个元素的值修改为原值的2倍。

-
var numbers = [1, 2, 3, 4, 5];
-var length = numbers.length;
-for (var i = 0; i < length; i++) {
-  numbers[i] *= 2;
-}
-// 遍历后的结果 [2, 4, 6, 8, 10]
+
var numbers = [1, 2, 3, 4, 5];
+var length = numbers.length;
+for (var i = 0; i < length; i++) {
+  numbers[i] *= 2;
+}
+// 遍历后的结果 [2, 4, 6, 8, 10]

截断数组

下面的例子中,如果数组长度大于 3,则把该数组的长度截断为 3 。

-
var numbers = [1, 2, 3, 4, 5];
+
var numbers = [1, 2, 3, 4, 5];
 
-if (numbers.length > 3) {
-  numbers.length = 3;
-}
+if (numbers.length > 3) {
+  numbers.length = 3;
+}
 
-console.log(numbers); // [1, 2, 3]
-console.log(numbers.length); // 3
+console.log(numbers); // [1, 2, 3] +console.log(numbers.length); // 3

规范

-- cgit v1.2.3-54-g00ecf