Mention endianness and alignment in section ArrayBuffers, binary arrays

Open Beginner friendly
#2,581 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
65/100
Issue type
Documentation
Clarity
Mostly clear
Activity status
Stale
Tech stack
javascript
Domain
documentation

Research direction

Find the tutorial section titled “ArrayBuffers, binary arrays” and review the existing explanation around typed arrays and DataView. Add clear notes covering alignment restrictions and the endianness distinction described in the issue, including the relevant behavior for Uint16Array and dataView.getUint16(). Done when readers can understand both caveats from that section.

Written by the indexing model from the issue text.

Description

PR wanted
  • Alignment: My browser (Firefox 87.0 on Linux x86_64) doesn't let me create an unaligned Uint16Array. I. e., new Uint16Array(b, 1, 1) on a 4-byte array buffer gives RangeError: attempting to construct out-of-bounds TypedArray on ArrayBuffer. In the standard that is 22.2.1.5.13a.

  • Endianness: Uint16Array is little-endian on my machine. I just learned that this is machine dependent (https://stackoverflow.com/questions/7869752/javascript-typed-arrays-and-endianness). In contrast, dataView.getUint16() is big-endian, unless the second argument is true.

Hope this helps.

Dominant language
HTML
Stars
25.5k
Forks
4k
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from javascript-tutorial/en.javascript.info

All issues in javascript-tutorial/en.javascript.info

Similar issues

More Documentation issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.