Skip to content

Commit 67d683f

Browse files
authored
Merge pull request javascript-tutorial#366 from odsantos/update-en-arraybuffer-binary-arrays
Update "ArrayBuffer, binary arrays" files
2 parents 32026ed + 284f43d commit 67d683f

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

4-binary/01-arraybuffer-binary-arrays/01-concat/_js.view/solution.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ function concat(arrays) {
22
// sum of individual array lengths
33
let totalLength = arrays.reduce((acc, value) => acc + value.length, 0);
44

5-
if (!arrays.length) return null;
6-
75
let result = new Uint8Array(totalLength);
6+
7+
if (!arrays.length) return result;
88

99
// for each array - copy it over result
1010
// next array is copied right after the previous one

4-binary/01-arraybuffer-binary-arrays/article.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ Let's eliminate a possible source of confusion. `ArrayBuffer` has nothing in com
3030
3131
**To manipulate an `ArrayBuffer`, we need to use a "view" object.**
3232
33-
A view object does not store anything on it's own. It's the "eyeglasses" that give an interpretation of the bytes stored in the `ArrayBuffer`.
33+
A view object does not store anything on its own. It's the "eyeglasses" that give an interpretation of the bytes stored in the `ArrayBuffer`.
3434
3535
For instance:
3636
@@ -71,7 +71,7 @@ for(let num of view) {
7171

7272
## TypedArray
7373

74-
The common term for all these views (`Uint8Array`, `Uint32Array`, etc) is [TypedArray](https://tc39.github.io/ecma262/#sec-typedarray-objects). They share the same set of methods and properities.
74+
The common term for all these views (`Uint8Array`, `Uint32Array`, etc) is [TypedArray](https://tc39.github.io/ecma262/#sec-typedarray-objects). They share the same set of methods and properties.
7575

7676
Please note, there's no constructor called `TypedArray`, it's just a common "umbrella" term to represent one of views over `ArrayBuffer`: `Int8Array`, `Uint8Array` and so on, the full list will soon follow.
7777

0 commit comments

Comments
 (0)