StylePropertyMapReadOnly: entries() method

可用性有限

此特性不是基線特性,因為它在一些最廣泛使用的瀏覽器中不起作用。

StylePropertyMapReadOnly.entries() 方法返回給定物件自身可列舉屬性的 [key, value] 對陣列,其順序與 for...in 迴圈提供的順序相同(區別在於 for-in 迴圈還會列舉原型鏈中的屬性)。

語法

js
entries()

引數

無。

返回值

給定 StylePropertyMapReadOnly 物件的自身可列舉屬性的 [key, value] 對陣列。

示例

這裡展示了一個在元素計算樣式上使用 StylePropertyMapReadOnly.entries() 方法的示例。

js
// grab a DOM element
const buttonEl = document.querySelector("button");

// we can retrieve all computed styles with `computedStyleMap`
const allComputedStyles = buttonEl.computedStyleMap();

// entries returns an iterable of the items
const iterableStyles = allComputedStyles.entries();

// returns a two item array with align-content as the first item and CSSStyleValue as the second
console.log(iterableStyles.next().value);

規範

此特性似乎未在任何規範中定義。

瀏覽器相容性