JavaScript ArrayBuffer maxByteLength Property Last Updated : 23 Jul, 2025 Comments Improve Suggest changes Like Article Like Report JavaScript maxByteLength in ArrayBuffer is used to set the maximum size of ArrayBuffer in bytes. This specified length is the maximum length to which we can resize the ArrayBuffer. This is a read-only property and can only be set when the ArrayBuffer object is created and cannot be changed afterward. If this property is left blank it is by default set to the byteLength specified during object creation. Syntax: {maxByteLength: val} // To set max value arr.maxByteLength // To get max value Parameter: It has one parameter only Return Value: When used as a getter it returns the maximum value in Number. Example 1: This example will set the maximum value and print it on the console. JavaScript let arr = new ArrayBuffer(8, { maxByteLength: 24 }); console.log(arr.maxByteLength); arr.resize(28); Output: When we try to resize the array beyond it's maximum capacity it will throw an error. Example 2: This example will try to increase the byteLength beyond it's capacity. HTML <!DOCTYPE html> <html lang="en"> <head> </head> <body style="text-align:center;"> <h1 style="color:green"> GeeksforGeeks </h1> <p> Size of ArrayBuffer: </p> <p id="gfg"></p> <button onclick="increase()"> Click here to increase size </button> <script> let arr1 = new ArrayBuffer(22, { maxByteLength: 24 }); document.getElementById("gfg") .innerHTML = arr1.byteLength; function increase() { console.log("hello"); if (arr1.byteLength == arr1.maxByteLength) { document.getElementById("gfg") .innerHTML = "Maximum capacity reached"; } else { arr1.resize(arr1.byteLength + 1); document.getElementById("gfg") .innerHTML = arr1.byteLength; } } </script> </body> </html> Output: JavaScript ArrayBuffer.maxByteLength property Supported Browsers: ChromeEdgeSafari We have a complete list of ArrayBuffer methods and properties, to check Please go through the JavaScript ArrayBuffer Reference article. Comment More info S shobhit_sharma Follow Improve Article Tags : JavaScript Web Technologies Explore JavaScript BasicsIntroduction to JavaScript4 min readVariables and Datatypes in JavaScript6 min readJavaScript Operators5 min readControl Statements in JavaScript4 min readArray & StringJavaScript Arrays7 min readJavaScript Array Methods7 min readJavaScript Strings6 min readJavaScript String Methods9 min readFunction & ObjectFunctions in JavaScript5 min readJavaScript Function Expression3 min readFunction Overloading in JavaScript4 min readObjects in Javascript4 min readJavaScript Object Constructors4 min readOOPObject Oriented Programming in JavaScript3 min readClasses and Objects in JavaScript4 min readWhat Are Access Modifiers In JavaScript ?5 min readJavaScript Constructor Method7 min readAsynchronous JavaScriptAsynchronous JavaScript2 min readJavaScript Callbacks4 min readJavaScript Promise4 min readEvent Loop in JavaScript4 min readAsync and Await in JavaScript2 min readException HandlingJavascript Error and Exceptional Handling6 min readJavaScript Errors Throw and Try to Catch2 min readHow to create custom errors in JavaScript ?2 min readJavaScript TypeError - Invalid Array.prototype.sort argument1 min readDOMHTML DOM (Document Object Model)9 min readHow to select DOM Elements in JavaScript ?3 min readJavaScript Custom Events4 min readJavaScript addEventListener() with Examples9 min readAdvanced TopicsClosure in JavaScript4 min readJavaScript Hoisting6 min readJavascript Scope3 min readJavaScript Higher Order Functions7 min readDebugging in JavaScript4 min read Like