Skip to content

Commit

Permalink
doc: clarify out-of-bounds behavior of buf[index]
Browse files Browse the repository at this point in the history
PR-URL: #11286
Fixes: #11244
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Gibson Fahnestock <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Ron Korving <[email protected]>
  • Loading branch information
seishun authored and MylesBorins committed Apr 24, 2017
1 parent eddfd52 commit 03f9388
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions doc/api/buffer.md
Original file line number Diff line number Diff line change
Expand Up @@ -872,6 +872,10 @@ The index operator `[index]` can be used to get and set the octet at position
`index` in `buf`. The values refer to individual bytes, so the legal value
range is between `0x00` and `0xFF` (hex) or `0` and `255` (decimal).

This operator is inherited from `Uint8Array`, so its behavior on out-of-bounds
access is the same as `UInt8Array` - that is, getting returns `undefined` and
setting does nothing.

Example: Copy an ASCII string into a `Buffer`, one byte at a time

```js
Expand Down

0 comments on commit 03f9388

Please sign in to comment.