Navigator.deviceMemory

翻译不完整。 请帮助我们翻译这篇文章!

这是一个实验中的功能
此功能某些浏览器尚在开发中,请参考浏览器兼容性表格以得到在不同浏览器中适合使用的前缀。由于该功能对应的标准文档可能被重新修订,所以在未来版本的浏览器中该功能的语法和行为可能随之改变。

deviceMemory 只读属性返回千兆字节为单位的大概的机器内存。这个值是一个2的次方数除以1024,舍去小数点的近似值。并且,上下边界也用来保护那些拥有非常低端或者高端设备的用户的隐私。

语法

const memory = navigator.deviceMemory
console.log ("This device has at least " + memory + "GiB of RAM.")

Value

一个浮点类型的数,0.25,0.5,1,2,4,8之一.

Specifications

Specification Status Comment
Device Memory 1
deviceMemory
Editor's Draft Initial definition.

Browser compatibility

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
deviceMemory
Experimental
Chrome Full support 63Edge Full support 79Firefox No support NoIE No support NoOpera Full support 50Safari No support NoWebView Android Full support 63Chrome Android Full support 63Firefox Android No support NoOpera Android Full support 46Safari iOS No support NoSamsung Internet Android Full support 8.0

Legend

Full support  
Full support
No support  
No support
Experimental. Expect behavior to change in the future.
Experimental. Expect behavior to change in the future.