Atomics.store

Atomics.store

静态的Atomics.store()方法将给定的值存储在数组中的指定位置,并返回该值。.

语法

Atomics.store(typedArray, index, value)

参数

typedArray一个指定类型的shared数组. 类型为Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array, 或者 Uint32Array其中一个.

返回值

被存储的值.

异常

  • 抛出一个TypeError异常, 如果 typedArray 不是上述给定的类型之一.

  • 抛出一个TypeError异常, 如果 typedArray 不是一个指定类型的shared类型数组.

  • 抛出一个RangeError异常, 如果 index 在 typedArray中越界了。

示例

var sab = new SharedArrayBuffer(1024 var ta = new Uint8Array(sab Atomics.store(ta, 0, 12 // 12

规范

SpecificationStatusComment
ECMAScript Latest Draft (ECMA-262)The definition of 'Atomics.store' in that specification.Living StandardInitial definition in ES2017.

浏览器兼容性

FeatureChromeEdgeFirefox (Gecko)Internet ExplorerOperaSafari
Basic supportNo support 2No 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