pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://developer.mozilla.org/ru/docs/Web/JavaScript/Reference/Global_Objects/DataView/byteLength

cript>

This page was translated from English by the community. Learn more and join the MDN Web Docs community.

View in English Always switch to English

DataView.prototype.byteLength

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since июль 2015 г..

Свойство-геттер byteLength возвращает длину DataView в байтах.

Интерактивный пример

// Create an ArrayBuffer with a size in bytes
const buffer = new ArrayBuffer(16);

const view1 = new DataView(buffer);
const view2 = new DataView(buffer, 12, 4); // From byte 12 for the next 4 bytes

console.log(view1.byteLength + view2.byteLength); // 16 + 4
// Expected output: 20

Описание

Свойство byteLength доступно только для чтения. Его значение определяется при создании объекта DataView и не может быть изменено. Если при создании DataView не были переданы параметры byteOffset или byteLength, то свойство будет равно byteLength связанного ArrayBuffer или SharedArrayBuffer.

Примеры

Использование свойства byteLength

js
const buffer = new ArrayBuffer(8);
const dataview = new DataView(buffer);
dataview.byteLength; // 8 (соответствует byteLength буфера)

const dataview2 = new DataView(buffer, 1, 5);
dataview2.byteLength; // 5 (как указано при создании DataView)

const dataview3 = new DataView(buffer, 2);
dataview3.byteLength; // 6 (из-за byteOffset, заданного при создании DataView)

Спецификации

Specification
ECMAScript® 2027 Language Specification
# sec-get-dataview.prototype.bytelength

Совместимость с браузерами

Смотрите также

pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy