byteLength
BufferConstructor.byteLength
**byteLength**(string, encoding?): number
Returns the byte length of a string when encoded using encoding.
This is not the same as String.prototype.length, which does not account
for the encoding that is used to convert the string into bytes.
For 'base64', 'base64url', and 'hex', this function assumes valid input.
For strings that contain non-base64/hex-encoded data (e.g. whitespace), the
return value might be greater than the length of a Buffer created from the
string.
When string is a
Buffer/DataView/[TypedArray](https://developer.mozilla.org/en-US/docs/Web/JavaScript/-
Reference/Global_Objects/TypedArray)/ArrayBuffer/[SharedArrayBuffer](https://develop-
er.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer), the byte length as reported by .byteLengthis returned.
Parameters
encodingBufferEncodingstring is a string, this is its encoding.Returns
number
numbernumberstring.Since
v0.1.90