Baseline Widely available
La méthode TypedArray.of()
crée un nouvel objet TypedArray
à partir d'un nombre variable d'arguments. Cette méthode est similaire à Array.of()
.
élémentN
Les éléments avec lesquels on souhaite construire le nouveau tableau typé.
Une nouvelle instance de TypedArray
.
Il existe de légères différences entre Array.of()
et TypedArray.of()
:
this
passée à TypedArray.of
n'est pas un constructeur, TypedArray.of
lèvera une exception TypeError
, tandis que Array.of
créera un nouvel objet Array
.TypedArray.of
utilise [[Put]]
tandis que Array.of
utilise [[DefineProperty]]
. Ainsi lorsque les arguments sont des objets Proxy
la première méthode appellera handler.set
pour créer les nouveaux éléments et la seconde appellera handler.defineProperty
.Uint8Array.of(1); // Uint8Array [ 1 ]
Int8Array.of("1", "2", "3"); // Int8Array [ 1, 2, 3 ]
Float32Array.of(1, 2, 3); // Float32Array [ 1, 2, 3 ]
Int16Array.of(undefined); // Int16Array [ 0 ]
Spécifications Compatibilité des navigateurs Voir aussi
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4