| [ Web Proxy ] |
| Viewing: https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Int16Array | [Back] [Original] |
Get to know MDN better
Int16Array() Int16Array
Int16Array.BYTES_PER_ELEMENT Int16Array 2
Int16Array.prototype Int16Array
Int16Array.prototype.BYTES_PER_ELEMENT Int16Array 2
Int16Array.prototype.constructor Int16Array Int16Array
//
const int16 = new Int16Array(2);
int16[0] = 42;
console.log(int16[0]); // 42
console.log(int16.length); // 2
console.log(int16.BYTES_PER_ELEMENT); // 2
//
const x = new Int16Array([21, 31]);
console.log(x[1]); // 31
// TypedArray
const y = new Int16Array(x);
console.log(y[0]); // 21
// ArrayBuffer
const buffer = new ArrayBuffer(16);
const z = new Int16Array(buffer, 2, 4);
console.log(z.byteOffset); // 2
//
const iterable = (function* () {
yield* [1, 2, 3];
})();
const int16FromIterable = new Int16Array(iterable);
console.log(int16FromIterable);
// Int16Array [1, 2, 3]
| ECMAScript 2027 LanguageSpecification # sec-typedarray-objects |
Int16ArrayTypedArrayat()TypedArray.prototype.copyWithin()TypedArray.prototype.entries()TypedArray.prototype.every()TypedArray.prototype.fill()TypedArray.prototype.filter()TypedArray.prototype.find()TypedArray.prototype.findIndex()findLast()findLastIndex()TypedArray.prototype.forEach()TypedArray.prototype.includes()TypedArray.prototype.indexOf()TypedArray.prototype.join()TypedArray.prototype.keys()TypedArray.prototype.lastIndexOf()TypedArray.prototype.map()TypedArray.prototype.reduce()TypedArray.prototype.reduceRight()TypedArray.prototype.reverse()set()slice()TypedArray.prototype.some()TypedArray.prototype.sort()TypedArray.prototype.subarray()TypedArray.prototype.toLocaleString()toReversed()TypedArray.prototype.toSorted()toString()TypedArray.prototype.values()TypedArray.prototype.with()TypedArray.prototype[Symbol.iterator]()Object/FunctionObject.prototype.__defineGetter__()Object.prototype.__defineSetter__()Object.prototype.__lookupGetter__()Object.prototype.__lookupSetter__()Object.prototype.hasOwnProperty()Object.prototype.isPrototypeOf()Object.prototype.propertyIsEnumerable()Object.prototype.toLocaleString()Object.prototype.toString()Object.prototype.valueOf()BigInt64ArrayBigUint64ArrayFloat16ArrayFloat32ArrayFloat64ArrayInt8ArrayInt32ArrayUint8ArrayUint8ClampedArrayUint16ArrayUint32Array| Web Proxy Viewer | New URL | Original Page |