diff --git a/files/en-us/web/javascript/reference/global_objects/typedarray/@@iterator/index.md b/files/en-us/web/javascript/reference/global_objects/typedarray/@@iterator/index.md index bc2077158577c72..f47b6a59fe141a4 100644 --- a/files/en-us/web/javascript/reference/global_objects/typedarray/@@iterator/index.md +++ b/files/en-us/web/javascript/reference/global_objects/typedarray/@@iterator/index.md @@ -37,7 +37,7 @@ The array **iterator** function, which is the const arr = new Uint8Array([10, 20, 30, 40, 50]); // your browser must support for..of loop // and let-scoped variables in for loops -for (let n of arr) { +for (const n of arr) { console.log(n); } ``` diff --git a/files/en-us/web/javascript/reference/global_objects/typedarray/indexof/index.md b/files/en-us/web/javascript/reference/global_objects/typedarray/indexof/index.md index 75b1f2360ccac06..7fd8ce8ea9df84e 100644 --- a/files/en-us/web/javascript/reference/global_objects/typedarray/indexof/index.md +++ b/files/en-us/web/javascript/reference/global_objects/typedarray/indexof/index.md @@ -49,14 +49,14 @@ The first index of the element in the array; `-1` if not found. `indexOf` compares `searchElement` to elements of the typed array using [strict equality](/en-US/docs/Web/JavaScript/Reference/Operators#using_the_equality_operators) -(the same method used by the ===, or triple-equals, operator). +(the same method used by the `===`, or triple-equals, operator). ## Examples ### Using indexOf ```js -var uint8 = new Uint8Array([2, 5, 9]); +const uint8 = new Uint8Array([2, 5, 9]); uint8.indexOf(2); // 0 uint8.indexOf(7); // -1 uint8.indexOf(9, 2); // 2 diff --git a/files/en-us/web/javascript/reference/global_objects/typedarray/join/index.md b/files/en-us/web/javascript/reference/global_objects/typedarray/join/index.md index 9d73fd8a78f4d3f..4bf09d4f3e1f6d3 100644 --- a/files/en-us/web/javascript/reference/global_objects/typedarray/join/index.md +++ b/files/en-us/web/javascript/reference/global_objects/typedarray/join/index.md @@ -43,7 +43,7 @@ A string with all array elements joined. ### Using join() ```js -var uint8 = new Uint8Array([1,2,3]); +const uint8 = new Uint8Array([1,2,3]); uint8.join(); // '1,2,3' uint8.join(' / '); // '1 / 2 / 3' uint8.join(''); // '123' diff --git a/files/en-us/web/javascript/reference/global_objects/typedarray/keys/index.md b/files/en-us/web/javascript/reference/global_objects/typedarray/keys/index.md index 5f0b07765c2ac9e..2b94e079df72d8d 100644 --- a/files/en-us/web/javascript/reference/global_objects/typedarray/keys/index.md +++ b/files/en-us/web/javascript/reference/global_objects/typedarray/keys/index.md @@ -35,11 +35,11 @@ A new _array iterator_ object. ### Iteration using for...of loop ```js -var arr = new Uint8Array([10, 20, 30, 40, 50]); -var eArray = arr.keys(); +const arr = new Uint8Array([10, 20, 30, 40, 50]); +const eArray = arr.keys(); // your browser must support for..of loop // and let-scoped variables in for loops -for (let n of eArray) { +for (const n of eArray) { console.log(n); } ``` diff --git a/files/en-us/web/javascript/reference/global_objects/typedarray/lastindexof/index.md b/files/en-us/web/javascript/reference/global_objects/typedarray/lastindexof/index.md index ddb3643dc57ba26..45e4eacc08c4577 100644 --- a/files/en-us/web/javascript/reference/global_objects/typedarray/lastindexof/index.md +++ b/files/en-us/web/javascript/reference/global_objects/typedarray/lastindexof/index.md @@ -56,7 +56,7 @@ The last index of the element in the array; `-1` if not found. ### Using lastIndexOf ```js -var uint8 = new Uint8Array([2, 5, 9, 2]); +const uint8 = new Uint8Array([2, 5, 9, 2]); uint8.lastIndexOf(2); // 3 uint8.lastIndexOf(7); // -1 uint8.lastIndexOf(2, 3); // 3 diff --git a/files/en-us/web/javascript/reference/global_objects/typedarray/length/index.md b/files/en-us/web/javascript/reference/global_objects/typedarray/length/index.md index 32fbbde6e700be2..f514a7718054c96 100644 --- a/files/en-us/web/javascript/reference/global_objects/typedarray/length/index.md +++ b/files/en-us/web/javascript/reference/global_objects/typedarray/length/index.md @@ -24,15 +24,15 @@ The `length` property is an accessor property whose set accessor function is `un ### Using the `length` property ```js -var buffer = new ArrayBuffer(8); +const buffer = new ArrayBuffer(8); -var uint8 = new Uint8Array(buffer); +let uint8 = new Uint8Array(buffer); uint8.length; // 8 (matches the length of the buffer) -var uint8 = new Uint8Array(buffer, 1, 5); +uint8 = new Uint8Array(buffer, 1, 5); uint8.length; // 5 (as specified when constructing the Uint8Array) -var uint8 = new Uint8Array(buffer, 2); +uint8 = new Uint8Array(buffer, 2); uint8.length; // 6 (due to the offset of the constructed Uint8Array) ``` diff --git a/files/en-us/web/javascript/reference/global_objects/typedarray/reduce/index.md b/files/en-us/web/javascript/reference/global_objects/typedarray/reduce/index.md index f2afb531cfd5896..36f0db09a626812 100644 --- a/files/en-us/web/javascript/reference/global_objects/typedarray/reduce/index.md +++ b/files/en-us/web/javascript/reference/global_objects/typedarray/reduce/index.md @@ -96,7 +96,7 @@ value would be returned without calling `callbackFn`. ### Sum up all values within an array ```js -var total = new Uint8Array([0, 1, 2, 3]).reduce(function(a, b) { +const total = new Uint8Array([0, 1, 2, 3]).reduce(function(a, b) { return a + b; }); // total == 6 diff --git a/files/en-us/web/javascript/reference/global_objects/typedarray/reduceright/index.md b/files/en-us/web/javascript/reference/global_objects/typedarray/reduceright/index.md index cf29b79f9894fb4..755b42b2e101d93 100644 --- a/files/en-us/web/javascript/reference/global_objects/typedarray/reduceright/index.md +++ b/files/en-us/web/javascript/reference/global_objects/typedarray/reduceright/index.md @@ -100,7 +100,7 @@ value would be returned without calling `callbackFn`. ### Sum up all values within an array ```js -var total = new Uint8Array([0, 1, 2, 3]).reduceRight(function(a, b) { +const total = new Uint8Array([0, 1, 2, 3]).reduceRight(function(a, b) { return a + b; }); // total == 6 diff --git a/files/en-us/web/javascript/reference/global_objects/typedarray/reverse/index.md b/files/en-us/web/javascript/reference/global_objects/typedarray/reverse/index.md index eb0b5a4ce2b2b34..7e7419d740bf8fd 100644 --- a/files/en-us/web/javascript/reference/global_objects/typedarray/reverse/index.md +++ b/files/en-us/web/javascript/reference/global_objects/typedarray/reverse/index.md @@ -35,7 +35,7 @@ The reversed array. ### Using reverse ```js -var uint8 = new Uint8Array([1, 2, 3]); +const uint8 = new Uint8Array([1, 2, 3]); uint8.reverse(); console.log(uint8); // Uint8Array [3, 2, 1] diff --git a/files/en-us/web/javascript/reference/global_objects/typedarray/set/index.md b/files/en-us/web/javascript/reference/global_objects/typedarray/set/index.md index f82e9b0a9a21928..2f59cfad1bfb13d 100644 --- a/files/en-us/web/javascript/reference/global_objects/typedarray/set/index.md +++ b/files/en-us/web/javascript/reference/global_objects/typedarray/set/index.md @@ -52,8 +52,8 @@ beyond the end of the typed array. ### Using set() ```js -var buffer = new ArrayBuffer(8); -var uint8 = new Uint8Array(buffer); +const buffer = new ArrayBuffer(8); +const uint8 = new Uint8Array(buffer); uint8.set([1, 2, 3], 3); diff --git a/files/en-us/web/javascript/reference/global_objects/typedarray/subarray/index.md b/files/en-us/web/javascript/reference/global_objects/typedarray/subarray/index.md index c794fd363bafe2a..b341b5ca46e39a7 100644 --- a/files/en-us/web/javascript/reference/global_objects/typedarray/subarray/index.md +++ b/files/en-us/web/javascript/reference/global_objects/typedarray/subarray/index.md @@ -58,13 +58,13 @@ object's contents will impact the original object and vice versa. ### Using the subarray() method ```js -var buffer = new ArrayBuffer(8); -var uint8 = new Uint8Array(buffer); -uint8.set([1,2,3]); +const buffer = new ArrayBuffer(8); +const uint8 = new Uint8Array(buffer); +uint8.set([1, 2, 3]); console.log(uint8); // Uint8Array [ 1, 2, 3, 0, 0, 0, 0, 0 ] -var sub = uint8.subarray(0,4); +const sub = uint8.subarray(0, 4); console.log(sub); // Uint8Array [ 1, 2, 3, 0 ] ``` diff --git a/files/en-us/web/javascript/reference/global_objects/typedarray/tolocalestring/index.md b/files/en-us/web/javascript/reference/global_objects/typedarray/tolocalestring/index.md index 3c09185789c3573..0433fe99757590f 100644 --- a/files/en-us/web/javascript/reference/global_objects/typedarray/tolocalestring/index.md +++ b/files/en-us/web/javascript/reference/global_objects/typedarray/tolocalestring/index.md @@ -48,7 +48,7 @@ A string representing the elements of the typed array. ### Using toLocaleString ```js -var uint = new Uint32Array([2000, 500, 8123, 12, 4212]); +const uint = new Uint32Array([2000, 500, 8123, 12, 4212]); uint.toLocaleString(); // if run in a de-DE locale diff --git a/files/en-us/web/javascript/reference/global_objects/typedarray/tostring/index.md b/files/en-us/web/javascript/reference/global_objects/typedarray/tostring/index.md index f28227064e5afc0..df43346f76dee05 100644 --- a/files/en-us/web/javascript/reference/global_objects/typedarray/tostring/index.md +++ b/files/en-us/web/javascript/reference/global_objects/typedarray/tostring/index.md @@ -37,7 +37,7 @@ separated by commas. For example, the following code creates a typed array and u `toString` to convert the array to a string. ```js -var numbers = new Uint8Array([2, 5, 8, 1, 4]) +const numbers = new Uint8Array([2, 5, 8, 1, 4]) numbers.toString(); // "2,5,8,1,4" ``` @@ -51,7 +51,7 @@ If a browser doesn't support the `TypedArray.prototype.toString()` method yet, JavaScript will call the `toString` method of {{jsxref("Object")}}: ```js -var numbers = new Uint8Array([2, 5, 8, 1, 4]) +const numbers = new Uint8Array([2, 5, 8, 1, 4]) numbers.toString(); // "[object Uint8Array]" ```