★ wanayoo — archive 1999 https://developer.mozilla.org/ru/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/fillNouvelle recherche | Portail wanayoo
mozilla
Your Search Results

    TypedArray.prototype.fill()

    Наши волонтёры ещё не перевели данную статью на Русский. Присоединяйтесь к нам и помогите закончить эту работу!

    Summary

    The fill() method fills all the elements of a typed array from a start index to an end index with a static value. This method has the same algorithm as Array.prototype.fill(). TypedArray is one of the typed array types here.

    Syntax

    typedarray.fill(value[, start = 0[, end = this.length]])

    Parameters

    value
    Value to fill the typed array with.
    start
    Optional. Start index. Defaults to 0.
    end
    Optional. End index. Defaults to 0.

    Description

    The elements interval to fill is [start, end).

    The fill method takes up to three arguments value, start and end. The start and end arguments are optional with default values of 0 and the length of the this object.

    If start is negative, it is treated as length+start where length is the length of the array. If end is negative, it is treated as length+end.

    Examples

    new Uint8Array([1, 2, 3]).fill(4);         // Uint8Array [4, 4, 4]
    new Uint8Array([1, 2, 3]).fill(4, 1);      // Uint8Array [1, 4, 4]
    new Uint8Array([1, 2, 3]).fill(4, 1, 2);   // Uint8Array [1, 4, 3]
    new Uint8Array([1, 2, 3]).fill(4, 1, 1);   // Uint8Array [1, 2, 3]
    new Uint8Array([1, 2, 3]).fill(4, -3, -2); // Uint8Array [4, 2, 3]
    

    Specifications

    Specification Status Comment
    ECMAScript 6 (ECMA-262)
    The definition of 'TypedArray.prototype.fill' in that specification.
    Draft Initial definition.

    Browser compatibility

    Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
    Basic support Not supported 37 (37) Not supported Not supported Not supported
    Feature Android Chrome for Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
    Basic support Not supported Not supported 37 (37) Not supported Not supported Not supported

    See also

    Метки документа и участники

    Contributors to this page: fscholz
    Обновлялась последний раз: fscholz,
    Скрыть боковую панель