Tutorials References Exercises Videos Menu
Create Website Get Certified Upgrade

Node.js buffer includes() Method

❮ Buffer Module


Example

Check if a buffer incudes the phrase "welcome":

var buf = Buffer.from('Hello, and welcome to Rome!');

console.log(buf.includes('welcome'));
Run example »

Definition and Usage

The includes() method checks if a specified value is included in the buffer.

Returns true if the values is included, otherwise false.


Syntax

buffer.includes(value, start, encoding);

Parameter Values

Parameter Description
value Required. What to search for. Legal value types:
String
Buffer
Number (Integer)
start Optional. Where to begin the search. Default 0
encoding Optional. If the value is a string, this parameter is used to specify its encoding. Default "utf8"

Technical Details

Return Value: A Boolean
Node.js Version: 5.3.0

❮ Buffer Module