slice()
method returns a new
ArrayBuffer
whose contents are a copy of this
ArrayBuffer
's bytes from
begin
, inclusive, up to
end
, exclusive.
The source for this interactive example is stored in a GitHub repository. If you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request.
arraybuffer.slice(begin[, end])
begin
Zero-based byte index at which to begin slicing.
end
可选
ArrayBuffer
contains all bytes from begin to the end of this
ArrayBuffer
.
A new
ArrayBuffer
对象。
slice()
method copies up to, but not including, the byte indicated by the
end
parameter. If either
begin
or
end
is negative, it refers to an index from the end of the array, as opposed to from the beginning.
The range specified by the
begin
and
end
parameters is clamped to the valid index range for the current array. If the computed length of the new
ArrayBuffer
would be negative, it is clamped to zero.
ArrayBuffer
const buf1 = new ArrayBuffer(8); const buf2 = buf1.slice(0);
| 规范 |
|---|
|
ECMAScript (ECMA-262)
The definition of 'ArrayBuffer.prototype.slice' in that specification. |
| Desktop | Mobile | Server | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
slice
|
Chrome 17 | Edge 12 |
Firefox
12
|
IE 11 | Opera 12.1 | Safari 6 | WebView Android ≤37 | Chrome Android 18 |
Firefox Android
14
|
Opera Android 12.1 | Safari iOS 6 | Samsung Internet Android 1.0 | nodejs 0.12 |
完整支持
见实现注意事项。
ArrayBuffer
ArrayBuffer.isView()
ArrayBuffer.prototype.slice()
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()