mirror of
https://github.com/nodejs/node.git
synced 2026-11-30 11:55:44 -05:00
doc: clarify out-of-bounds behavior of buf[index]
PR-URL: https://github.com/nodejs/node/pull/11286 Fixes: https://github.com/nodejs/node/issues/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>
This commit is contained in:
1 parent
eddfd5230e
commit
03f9388eb7
1 file changed
+4
@@ -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
|
||||
|
||||
Reference in new issue
Block a user