Home >Web Front-end >JS Tutorial >Instructions for using the buffer.Buffer.isBuffer method in node.js_node.js

Instructions for using the buffer.Buffer.isBuffer method in node.js_node.js

WBOY
WBOYOriginal
2016-05-16 16:27:251568browse

Method description:

Detect whether the target is a buffer object. Will return true or false.

Grammar:

Copy code The code is as follows:

Buffer.isBuffer(obj)

Receive parameters:

obj The object being detected.

Example:

Copy code The code is as follows:

var b = new Buffer(50);

var c = b.toString('base64',0,10);

var d = Buffer.isEncoding('base64');

var e = Buffer.isBuffer(b);

console.log(d);                           //Return false

console.log(e); //Return true

Source code:

Copy code The code is as follows:

// Static methods
Buffer.isBuffer = function isBuffer(b) {
Return util.isBuffer(b);
};
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn