| [ Web Proxy ] |
| Viewing: https://developer.mozilla.org/fr/docs/Web/JavaScript/Reference/Global_Objects/Int16Array/Int16Array | [Back] [Original] |
Get to know MDN better
Cette page a t traduite partir de l'anglais par la communaut. Vous pouvez contribuer en rejoignant la communaut francophone sur MDN Web Docs.
Cette fonctionnalit est bien tablie et fonctionne sur de nombreux appareils et versions de navigateurs. Elle est disponible sur tous les navigateurs depuis juillet 2015.
Le constructeur Int16Array() cre des objets Int16Array. Les contenus sont initialiss 0 sauf si des donnes d'initialisation sont explicitement fournies.
new Int16Array()
new Int16Array(length)
new Int16Array(typedArray)
new Int16Array(object)
new Int16Array(buffer)
new Int16Array(buffer, byteOffset)
new Int16Array(buffer, byteOffset, length)
Note :
Int16Array() ne peut tre construit qu'avec new. Tenter de l'appeler sans new lve une erreur TypeError.
Voir TypedArray.
Voir TypedArray.
Int16Array// Construction partir d'une longueur
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
// Construction partir d'un tableau
const x = new Int16Array([21, 31]);
console.log(x[1]); // 31
// Construction partir d'un autre TypedArray
const y = new Int16Array(x);
console.log(y[0]); // 21
// Construction partir d'un ArrayBuffer
const buffer = new ArrayBuffer(16);
const z = new Int16Array(buffer, 2, 4);
console.log(z.byteOffset); // 2
// Construction partir d'un itrable
const iterable = (function* () {
yield* [1, 2, 3];
})();
const int16FromIterable = new Int16Array(iterable);
console.log(int16FromIterable);
// Int16Array [1, 2, 3]
| Spcification |
|---|
| ECMAScript 2027 LanguageSpecification # sec-typedarray-constructors |
Int16Array dans core-js (angl.)TypedArrayArrayBufferDataViewCette page a t modifie le 22 mai 2026 par les contributeurices du MDN.
Int16ArrayTypedArrayTypedArray.prototype.at()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()TypedArray.prototype.set()TypedArray.prototype.slice()TypedArray.prototype.some()TypedArray.prototype.sort()TypedArray.prototype.subarray()TypedArray.prototype.toLocaleString()toReversed()toSorted()TypedArray.prototype.toString()TypedArray.prototype.values()with()TypedArray.prototype[@@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()BigInt64ArrayBigUint64ArrayFloat16ArrayFloat32ArrayFloat64ArrayInt8ArrayInt32ArrayUint8ArrayUint8ClampedArrayUint16ArrayUint32ArrayCertaines parties de ce contenu sont protges par le droit d'auteur 19982026 des contributeurs individuels de mozilla.org. Contenu disponible sous une licence Creative Commons.
| Web Proxy Viewer | New URL | Original Page |