copyWithin()
method copies the sequence of array elements within the array to the position starting at
target
. The copy is taken from the index positions of the second and third arguments
start
and
end
。
end
argument is optional and defaults to the length of the array. This method has the same algorithm as
Array.prototype.copyWithin
.
TypedArray
is one of the
typed array types
here.
typedarray.copyWithin(target, start[, end = this.length])
target
Target start index position where to copy the elements to.
start
Source start index position where to start copying elements from.
end
可选
Optional. Source end index position where to end copying elements from.
The modified array.
见
Array.prototype.copyWithin
了解更多细节。
var buffer = new ArrayBuffer(8); var uint8 = new Uint8Array(buffer); uint8.set([1,2,3]); console.log(uint8); // Uint8Array [ 1, 2, 3, 0, 0, 0, 0, 0 ] uint8.copyWithin(3,0,3); console.log(uint8); // Uint8Array [ 1, 2, 3, 1, 2, 3, 0, 0 ]
| 规范 |
|---|
|
ECMAScript (ECMA-262)
The definition of 'TypedArray.prototype.copyWithin' in that specification. |
| Desktop | Mobile | Server | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
copyWithin
|
Chrome 45 | Edge 14 | Firefox 34 | IE No | Opera 36 | Safari 9.1 | WebView Android No | Chrome Android No | Firefox Android 34 | Opera Android No | Safari iOS 9.3 | Samsung Internet Android No | nodejs 4.0.0 |
完整支持
不支持
TypedArray
TypedArray.from()
TypedArray.of()
TypedArray.prototype.copyWithin()
TypedArray.prototype.entries()
TypedArray.prototype.every()
TypedArray.prototype.fill()
TypedArray.prototype.filter()
TypedArray.prototype.find()
TypedArray.prototype.findIndex()
TypedArray.prototype.forEach()
TypedArray.prototype.includes()
TypedArray.prototype.indexOf()
TypedArray.prototype.join()
TypedArray.prototype.keys()
TypedArray.prototype.lastIndexOf()
TypedArray.prototype.map()
TypedArray.prototype.reduce()
TypedArray.prototype.reduceRight()
TypedArray.prototype.reverse()
TypedArray.prototype.set()
TypedArray.prototype.slice()
TypedArray.prototype.some()
TypedArray.prototype.sort()
TypedArray.prototype.subarray()
TypedArray.prototype.toLocaleString()
TypedArray.prototype.toString()
TypedArray.prototype.values()
TypedArray.prototype[@@iterator]()
Int8Array
Uint8Array
Uint8ClampedArray
Int16Array
Uint16Array
Int32Array
Uint32Array
Float32Array
Float64Array
BigInt64Array
BigUint64Array
Function
Object
Object.prototype.__defineGetter__()
Object.prototype.__defineSetter__()
Object.prototype.__lookupGetter__()
Object.prototype.__lookupSetter__()
Object.prototype.hasOwnProperty()
Object.prototype.isPrototypeOf()
Object.prototype.propertyIsEnumerable()
Object.prototype.toLocaleString()
Object.prototype.toSource()
Object.prototype.toString()
Object.prototype.valueOf()
Object.setPrototypeOf()