Back to Content

StylePropertyMapReadOnly: keys() method

files/en-us/web/api/stylepropertymapreadonly/keys/index.md

latest865 B
Original Source

{{APIRef("CSS Typed Object Model API")}}

The StylePropertyMapReadOnly.keys() method returns a new array iterator containing the keys for each item in StylePropertyMapReadOnly

Syntax

js-nolint
keys()

Parameters

None.

Return value

A new {{jsxref("Array")}}.

Examples

In this example we use the keys() method to be able to access the properties within our {{domxref('Element.computedStyleMap()')}}.

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

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

// keys returns an iterable list of properties
const props = allComputedStyles.keys();
console.log(props.next().value); // returns align-content

Specifications

{{Specifications}}

Browser compatibility

{{Compat}}