Browse Source

doc: var => const/let in the buffer.md

PR-URL: https://github.com/nodejs/node/pull/9795
Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
Reviewed-By: Roman Reiss <me@silverwind.io>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
v6.x
Vse Mozhet Byt 8 years ago
committed by Myles Borins
parent
commit
b36c315423
No known key found for this signature in database GPG Key ID: 933B01F40B5CA946
  1. 20
      doc/api/buffer.md

20
doc/api/buffer.md

@ -1,4 +1,4 @@
# Buffer # Buffer
> Stability: 2 - Stable > Stability: 2 - Stable
@ -282,7 +282,7 @@ const buf = Buffer.from([1, 2, 3]);
// 1 // 1
// 2 // 2
// 3 // 3
for (var b of buf) { for (const b of buf) {
console.log(b); console.log(b);
} }
``` ```
@ -997,7 +997,7 @@ overlapping region within the same `Buffer`
```js ```js
const buf = Buffer.allocUnsafe(26); const buf = Buffer.allocUnsafe(26);
for (var i = 0 ; i < 26 ; i++) { for (let i = 0 ; i < 26 ; i++) {
// 97 is the decimal ASCII value for 'a' // 97 is the decimal ASCII value for 'a'
buf[i] = i + 97; buf[i] = i + 97;
} }
@ -1030,7 +1030,7 @@ const buf = Buffer.from('buffer');
// [3, 102] // [3, 102]
// [4, 101] // [4, 101]
// [5, 114] // [5, 114]
for (var pair of buf.entries()) { for (const pair of buf.entries()) {
console.log(pair); console.log(pair);
} }
``` ```
@ -1214,7 +1214,7 @@ const buf = Buffer.from('buffer');
// 3 // 3
// 4 // 4
// 5 // 5
for (var key of buf.keys()) { for (const key of buf.keys()) {
console.log(key); console.log(key);
} }
``` ```
@ -1304,7 +1304,7 @@ use [`buf.slice()`] to create a new `Buffer`.
Examples: Examples:
```js ```js
var buf = Buffer.allocUnsafe(10); let buf = Buffer.allocUnsafe(10);
buf.write('abcdefghj', 0, 'ascii'); buf.write('abcdefghj', 0, 'ascii');
@ -1675,7 +1675,7 @@ one byte from the original `Buffer`
```js ```js
const buf1 = Buffer.allocUnsafe(26); const buf1 = Buffer.allocUnsafe(26);
for (var i = 0 ; i < 26 ; i++) { for (let i = 0 ; i < 26 ; i++) {
// 97 is the decimal ASCII value for 'a' // 97 is the decimal ASCII value for 'a'
buf1[i] = i + 97; buf1[i] = i + 97;
} }
@ -1824,7 +1824,7 @@ Examples:
```js ```js
const buf1 = Buffer.allocUnsafe(26); const buf1 = Buffer.allocUnsafe(26);
for (var i = 0 ; i < 26 ; i++) { for (let i = 0 ; i < 26 ; i++) {
// 97 is the decimal ASCII value for 'a' // 97 is the decimal ASCII value for 'a'
buf1[i] = i + 97; buf1[i] = i + 97;
} }
@ -1899,7 +1899,7 @@ const buf = Buffer.from('buffer');
// 102 // 102
// 101 // 101
// 114 // 114
for (var value of buf.values()) { for (const value of buf.values()) {
console.log(value); console.log(value);
} }
@ -1910,7 +1910,7 @@ for (var value of buf.values()) {
// 102 // 102
// 101 // 101
// 114 // 114
for (var value of buf) { for (const value of buf) {
console.log(value); console.log(value);
} }
``` ```

Loading…
Cancel
Save