A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/with below:

TypedArray.prototype.with() - JavaScript | MDN

TypedArray.prototype.with()

Baseline 2023

Newly available

The with() method of TypedArray instances is the copying version of using the bracket notation to change the value of a given index. It returns a new typed array with the element at the given index replaced with the given value. This method has the same algorithm as Array.prototype.with().

Syntax
arrayInstance.with(index, value)
Parameters
index

Zero-based index at which to change the typed array, converted to an integer.

value

Any value to be assigned to the given index.

Return value

A new typed array with the element at index replaced with value.

Exceptions
RangeError

Thrown if index >= array.length or index < -array.length.

Description

See Array.prototype.with() for more details. This method is not generic and can only be called on typed array instances.

Examples Using with()
const arr = new Uint8Array([1, 2, 3, 4, 5]);
console.log(arr.with(2, 6)); // Uint8Array [1, 2, 6, 4, 5]
console.log(arr); // Uint8Array [1, 2, 3, 4, 5]
Specifications Browser compatibility See also

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