Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / JavaScript

Object.values — values of an object's own properties

Object.values(obj) returns a new array of values from own, enumerable, string-keyed properties. It excludes inherited properties, non-enumerable properties, and Symbol keys.

Version: ECMAScript and Web APIs; exact feature edition and browser support reviewed per entry; Node 24 in repository does not prove browser API support

Syntax

Object.values(obj)

Object.values(obj) is a static method: call it on Object, not on the object being inspected. It returns a new array containing only the values of own, enumerable, string-keyed properties. It does not return keys or key–value pairs. Inherited properties, non-enumerable properties, and properties with Symbol keys are excluded.

For ordinary objects, array-index keys are processed first in ascending numeric order; other string keys follow in property creation order. This is neither value sorting nor alphabetical key sorting. In the example, key 2 precedes 10, and both precede label.

The argument is converted to an object. null and undefined throw TypeError; a string exposes enumerable indexed properties, so Object.values("abc") produces ["a","b","c"]. Ordinary number and boolean primitives have no own enumerable properties, so they produce [].

A new array does not mean a deep copy: object-valued entries remain references to the same objects. Reading values invokes getters, which can have side effects or throw exceptions. The method itself does not write source properties, but code invoked during reads can change them.

Examples

const record = Object.create({ inherited: "ignored" });
record.label = "item";
record[10] = "ten";
record[2] = "two";
Object.defineProperty(record, "hidden", { value: "ignored" });
record[Symbol("secret")] = "ignored";

console.log(JSON.stringify(Object.values(record)));

Result

["two","ten","item"]

The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.

Sources