sharedArrayBuffer.slice
sharedArrayBuffer.slice
SharedArrayBuffer.prototype.slice()
方法返回一个新的SharedArrayBuffer
其内容是该SharedArrayBuffer
的字节从开始包含,直到结束,独占的副本。如果开始或结束是负的,它指的是从数组末尾开始的索引。此方法与 Array.prototype.slice()
具有相同的算法。
句法
sab.slice()
sab.slice(begin)
sab.slice(begin, end)
参数
begin
基于零的索引开始提取。可以使用负索引,指示从序列末尾开始的偏移量。
返回值
一个新的SharedArrayBuffer
包含提取的元素。
示例
var sab = new SharedArrayBuffer(1024
sab.slice( // SharedArrayBuffer { byteLength: 1024 }
sab.slice(2 // SharedArrayBuffer { byteLength: 1022 }
sab.slice(-2 // SharedArrayBuffer { byteLength: 2 }
sab.slice(0, 1 // SharedArrayBuffer { byteLength: 1 }
规范
Specification | Status | Comment |
---|---|---|
ECMAScript Latest Draft (ECMA-262)The definition of 'SharedArrayBuffer.prototype.slice' in that specification. | Draft | Initial definition in ES2017. |
浏览器兼容性
Feature | Chrome | Edge | Firefox (Gecko) | Internet Explorer | Opera | Safari |
---|---|---|---|---|---|---|
Basic support | No support | No support | 55 (55) 1 | No support | No support | No support |
Feature | Android | Chrome for Android | Firefox Mobile (Gecko) | IE Mobile | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|---|
Basic support | No support | No support | 55.0 (55) 1 | No support | No support | No support |