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 }

规范

SpecificationStatusComment
ECMAScript Latest Draft (ECMA-262)The definition of 'SharedArrayBuffer.prototype.slice' in that specification.DraftInitial definition in ES2017.

浏览器兼容性

FeatureChromeEdgeFirefox (Gecko)Internet ExplorerOperaSafari
Basic supportNo supportNo support55 (55) 1No supportNo supportNo support

FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
Basic supportNo supportNo support55.0 (55) 1No supportNo supportNo support