Skip to content

Commit 01ffe30

Browse files
committed
doc: clarify out-of-bounds behavior of buf[index]
PR-URL: #11286 Fixes: #11244 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Ron Korving <ron@ronkorving.nl>
1 parent 642baf4 commit 01ffe30

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

doc/api/buffer.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -947,6 +947,10 @@ The index operator `[index]` can be used to get and set the octet at position
947947
`index` in `buf`. The values refer to individual bytes, so the legal value
948948
range is between `0x00` and `0xFF` (hex) or `0` and `255` (decimal).
949949

950+
This operator is inherited from `Uint8Array`, so its behavior on out-of-bounds
951+
access is the same as `UInt8Array` - that is, getting returns `undefined` and
952+
setting does nothing.
953+
950954
Example: Copy an ASCII string into a `Buffer`, one byte at a time
951955

952956
```js

0 commit comments

Comments
 (0)