From 95aca4b4d8fa62815d4bd412fff1a364f842814a Mon Sep 17 00:00:00 2001 From: Ryan Johnson Date: Thu, 29 Apr 2021 16:16:42 -0700 Subject: remove retired locales (#699) --- .../global_objects/array/length/index.html | 145 --------------------- .../reference/global_objects/promise/index.html | 66 ---------- 2 files changed, 211 deletions(-) delete mode 100644 files/vi/conflicting/web/javascript/reference/global_objects/array/length/index.html delete mode 100644 files/vi/conflicting/web/javascript/reference/global_objects/promise/index.html (limited to 'files/vi/conflicting/web/javascript/reference/global_objects') diff --git a/files/vi/conflicting/web/javascript/reference/global_objects/array/length/index.html b/files/vi/conflicting/web/javascript/reference/global_objects/array/length/index.html deleted file mode 100644 index 8a939194ca..0000000000 --- a/files/vi/conflicting/web/javascript/reference/global_objects/array/length/index.html +++ /dev/null @@ -1,145 +0,0 @@ ---- -title: Array.length -slug: conflicting/Web/JavaScript/Reference/Global_Objects/Array/length -translation_of: Web/JavaScript/Reference/Global_Objects/Array/length -original_slug: "Web/JavaScript/Reference/Global_Objects/Array/\blength" ---- -
{{JSRef}}
- -

Thuộc tính length của một mảng trả về số phần tử trong mảng đó. Đó là một số nguyên 32 bit không dấu và luôn lớn hơn chỉ mục lớn nhất của mảng (chỉ mục lớn nhất chính là dộ dài của mảng trừ đi 1).

- -
{{EmbedInteractiveExample("pages/js/array-length.html")}}
- - - -

Mô tả

- -

Giá trị hợp lệ mà length có thể biểu diễn là một số nguyên dương có miền giá trị nằm trong khoảng  2 đến 232.

- -
var namelistA = new Array(4294967296); //2 to the 32nd power = 4294967296
-var namelistC = new Array(-100) //negative sign
-
-console.log(namelistA.length); //RangeError: Invalid array length
-console.log(namelistC.length); //RangeError: Invalid array length
-
-
-
-var namelistB = [];
-namelistB.length = Math.pow(2,32)-1; //set array length less than 2 to the 32nd power
-console.log(namelistB.length);
-
-//4294967295
-
- -

length  có thể được dùng để thay đổi số lượng phần tử có trong mảng bằng cách gán lại giá trị của length .  Trong ví dụ dưới đây, khi mảng chỉ có 2 phần tử nhưng ta thay đổi length thành 3 thì mảng sẽ tự động có thêm một phần tử mới. Tuy nhiên việc cố tình thay đổi này sẽ hình thành phần tử mới mang giá trị undefined.

- -
var arr = [1, 2, 3];
-printEntries(arr);
-
-arr.length = 5; // set array length to 5 while currently 3.
-printEntries(arr);
-
-function printEntries(arr) {
-  var length = arr.length;
-  for (var i = 0; i < length; i++) {
-    console.log(arr[i]);
-  }
-  console.log('=== printed ===');
-}
-
-// 1
-// 2
-// 3
-// === printed ===
-// 1
-// 2
-// 3
-// undefined
-// undefined
-// === printed ===
- -

Thực sự thì bản chất của length property không thể hiện số phần tử 'defined' có trong mảng. Tham khảo thêm từ Relationship between length and numerical properties.

- -

{{js_property_attributes(1, 0, 0)}}

- -
- -
- -

Ví dụ

- -

Duyệt mảng

- -

Trong ví dụ sau, việc duyệt một mảng với các phần tử kiểu numbers  có thể được thực hiện thông qua length. Tại mỗi bước, giá trị của mảng được gán lại gấp đôi.

- -
var numbers = [1, 2, 3, 4, 5];
-var length = numbers.length;
-for (var i = 0; i < length; i++) {
-  numbers[i] *= 2;
-}
-// numbers is now [2, 4, 6, 8, 10]
-
- -

Cẳt mảng

- -

Trong phần mô tả ở trên, nếu length có thể dùng để tăng thêm số phần tử trong mảng thì ta có thể dùng length để cắt bớt số phần tử trong mảng. Ví dụ dưới đây minh hoạ cho việc cắt bớt 2 phần tử cuối có trong mảng 5 phần tử.

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

 Đặc tả

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Đặc tả Tình trạngGhi chú
{{SpecName('ES1')}}{{Spec2('ES1')}}Định nghĩa lần đâu
{{SpecName('ES5.1', '#sec-15.4.5.2', 'Array.length')}}{{Spec2('ES5.1')}}
{{SpecName('ES6', '#sec-properties-of-array-instances-length', 'Array.length')}}{{Spec2('ES6')}}
{{SpecName('ESDraft', '#sec-properties-of-array-instances-length', 'Array.length')}}{{Spec2('ESDraft')}}
- -

Tính tương thích

- -
- - -

{{Compat("javascript.builtins.Array.length")}}

-
- -

Liên quan

- - diff --git a/files/vi/conflicting/web/javascript/reference/global_objects/promise/index.html b/files/vi/conflicting/web/javascript/reference/global_objects/promise/index.html deleted file mode 100644 index 5fda2aba9f..0000000000 --- a/files/vi/conflicting/web/javascript/reference/global_objects/promise/index.html +++ /dev/null @@ -1,66 +0,0 @@ ---- -title: Promise.prototype -slug: conflicting/Web/JavaScript/Reference/Global_Objects/Promise -translation_of: Web/JavaScript/Reference/Global_Objects/Promise -translation_of_original: Web/JavaScript/Reference/Global_Objects/Promise/prototype -original_slug: Web/JavaScript/Reference/Global_Objects/Promise/prototype ---- -
{{JSRef}}
- -

Thuộc tính Promise.prototype biểu diễn nguyên mẫu (prototype) cho hàm khởi tạo của {{jsxref("Promise")}}.

- -
{{js_property_attributes(0,0,0)}}
- -

Mô tả

- -

Mỗi đối tượng {{jsxref("Promise")}} được kế thừa từ {{jsxref("Promise.prototype")}}. Ta có thể sử dụng nguyên mẫu của hàm khởi tạo để thêm vào các thuộc tính hoặc phương thức mới cho đối tượng Promise.

- -

Thuộc tính

- -
-
Promise.prototype.constructor
-
Trả ra hàm khởi tạo một nguyên mẫu đối tượng. Mặc định là hàm {{jsxref("Promise")}}.
-
- -

Phương thức

- -
-
{{jsxref("Promise.catch", "Promise.prototype.catch(onRejected)")}}
-
Thêm một hàm phản hồi lỗi cho promise và trả ra một promise mới chứa kết quả được truyền vào hàm phản hồi đó sau khi thao tác xử lý của promise kết thúc.
-
{{jsxref("Promise.then", "Promise.prototype.then(onFulfilled, onRejected)")}}
-
Thêm một hàm phản hồi (có thể là thành công hoặc thất bại) và trả ra một promise mới chứa kết quả là kết quả thực thi của promise sau khi tác vụ kết thúc. Trong đó onFulfilled sẽ có đầu vòa là kết quả xử lý thành công, còn onRejected có đầu vòa là kết quả xử lý thất bại.
-
- -

Đặc tả

- - - - - - - - - - - - - - - - - - - -
Đặc tảTrạng tháiGhi chú
{{SpecName('ES6', '#sec-promise.prototype', 'Promise.prototype')}}{{Spec2('ES6')}}Initial definition.
{{SpecName('ESDraft', '#sec-promise.prototype', 'Promise.prototype')}}{{Spec2('ESDraft')}} 
- -

Trình duyệt tương thích

- - - -

{{Compat}}

- -

See also

- - -- cgit v1.2.3-54-g00ecf