![]() |
A new method TypedArray.prototype.with(), was introduced in ECMAScript 2023 (ES2023) to provide a means of modifying an element in a particular TypedArray without altering the underlying array directly, it generates a new TypedArray with the required alteration and then returns it. TypedArray instances with() method copies to changing a value at a particular index through bracket notation, giving back a fresh typed array where the value at the specified index is substituted with the specified one, Array.prototype.with() employs an equivalent procedure. SyntaxTypedArray.prototype.with(index, value) Parameter:
Return Type:A new typed array with the element Example 1: In this example, we are replacing an element.
Output: Int8Array(5) [1, 3, 5, 7, 9] Example 2: In this example, we are chaining with other methods.
Output: Uint8Array(6) [255, 0, 0, 0, 255, 0]
|
Reffered: https://www.geeksforgeeks.org
JavaScript |
Type: | Geek |
Category: | Coding |
Sub Category: | Tutorial |
Uploaded by: | Admin |
Views: | 15 |