Navigator:deviceMemory 属性
Limited availability
This feature is not Baseline because it does not work in some of the most widely-used browsers.
Navigator
接口的只读属性 deviceMemory
返回设备内存的近似值(以千兆字节为单位)。
为了防止指纹识别,报告的值并不精确。该值通过向下取整到最接近的 2 的幂,然后将其除以 1024 来近似。之后,将其限制在上下限范围内,以保护内存非常低或非常高的设备的所有者的隐私。
值
一个浮点数;取值范围为 0.25
、0.5
、1
、2
、4
、8
。
示例
js
const memory = navigator.deviceMemory;
console.log(`此设备至少拥有 ${memory}GiB 的 RAM。`);
规范
Specification |
---|
Device Memory # sec-device-memory-js-api |
浏览器兼容性
Report problems with this compatibility data on GitHubdesktop | mobile | server | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
deviceMemory |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
- No support
- No support
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
参见
Device-Memory
HTTP 标头