From 03f9388eb799c227c8dc8797f9a45eef84dc0400 Mon Sep 17 00:00:00 2001 From: Nikolai Vavilov Date: Fri, 10 Feb 2017 15:30:51 +0200 Subject: [PATCH] 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 Reviewed-By: Gibson Fahnestock Reviewed-By: Colin Ihrig Reviewed-By: Ron Korving --- doc/api/buffer.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/doc/api/buffer.md b/doc/api/buffer.md index 4c7734e0968a33..e884a7f2320f35 100644 --- a/doc/api/buffer.md +++ b/doc/api/buffer.md @@ -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