Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doc: adding example to Buffer.isBuffer method update buffer.md file #36233

Closed
wants to merge 5 commits into from
Closed
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions doc/api/buffer.md
Original file line number Diff line number Diff line change
Expand Up @@ -743,6 +743,25 @@ added: v0.1.101

Returns `true` if `obj` is a `Buffer`, `false` otherwise.

```js

ntedgi marked this conversation as resolved.
Show resolved Hide resolved
const buf1 = Buffer.alloc(10);
console.log(Buffer.isBuffer(buf1));
// Prints: true

const buf2 = Buffer.from('this is a test');
console.log(Buffer.isBuffer(buf2));
// Prints: true

const str = 'a string';
console.log(Buffer.isBuffer(str));
// Prints: false

const arr = [];
console.log(Buffer.isBuffer(arr));
// Prints: false

ntedgi marked this conversation as resolved.
Show resolved Hide resolved
```
### Static method: `Buffer.isEncoding(encoding)`
<!-- YAML
added: v0.9.1
Expand Down