javascript-tutorial / javascript-tutorial/en.javascript.info
Mention endianness and alignment in section ArrayBuffers, binary arrays
Nobody has claimed this yet.
- Dominant language
- HTML
- Stars
- 25.5k
- Forks
- 4k
- PR merge metrics
- No merged PRs in 30d
Description
* 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](https://262.ecma-international.org/6.0/#sec-%typedarray%-buffer-byteoffset-length).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](Stackoverflow)). In contrast, `dataView.getUint16()` is big-endian, unless the second argument is true.
Hope this helps.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
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.
Assessment
- Tech stack
- javascript
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 65/100