★ wanayoo — archive 1999 https://developer.mozilla.org/fr/docs/Web/JavaScript/Reference/Objets_globaux/TypedArray/ofNouvelle recherche | Portail wanayoo

Apply your JS skills to key Mozilla projects as an MDN Fellow! http://mzl.la/MDNFellowship

mozilla
Vos résultats de recherche

    TypedArray.of()

    Résumé

    La méthode TypedArray.of() crée un nouvel objet TypedArray avec un nombre variable d'arguments. Cette méthode est similaire à Array.of().

    Syntaxe

    TypedArray.of(élément0[, élément1[, ...[, élémentN]]])
    
    où TypedArray est l'un de :
    
    Int8Array
    Uint8Array
    Uint8ClampedArray
    Int16Array
    Uint16Array
    Int32Array
    Uint32Array
    Float32Array
    Float64Array

    Paramètres

    élémentN
    Les éléments avec lesquels on souhaite construire le nouveau tableau typé.

    Description

    Il existe de légères différences entre Array.of() et TypedArray.of() :

    • Si la valeur de 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.

    Exemples

    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);    // IntArray [ 0 ]
    

    Spécifications

    Spécification Statut Commentaires
    ECMAScript 6 (ECMA-262)
    La définition de '%TypedArray%.of' dans cette spécification.
    Draft Définition initiale au sein d'un standard ECMA.

    Compatibilité des navigateurs

    Fonctionnalité Chrome Firefox (Gecko) Internet Explorer Opera Safari
    Support simple Pas de support 38 (38) Pas de support Pas de support Pas de support
    Fonctionnalité Android Chrome pour Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
    Support simple Pas de support Pas de support 38.0 (38) Pas de support Pas de support Pas de support

    Voir aussi

    Étiquettes et contributeurs liés au document

    Contributors to this page: SphinxKnight, cdr
    Dernière mise à jour par : SphinxKnight,
    Masquer la barre latérale