Skip to content

Commit fade55b

Browse files
seishunMylesBorins
authored andcommitted
doc: clarify out-of-bounds behavior of buf[index]
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]>
1 parent 751c115 commit fade55b

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

doc/api/buffer.md

+4
Original file line numberDiff line numberDiff line change
@@ -939,6 +939,10 @@ The index operator `[index]` can be used to get and set the octet at position
939939
`index` in `buf`. The values refer to individual bytes, so the legal value
940940
range is between `0x00` and `0xFF` (hex) or `0` and `255` (decimal).
941941

942+
This operator is inherited from `Uint8Array`, so its behavior on out-of-bounds
943+
access is the same as `UInt8Array` - that is, getting returns `undefined` and
944+
setting does nothing.
945+
942946
Example: Copy an ASCII string into a `Buffer`, one byte at a time
943947

944948
```js

0 commit comments

Comments
 (0)