Object.entries(obj) Last updated: 17. Oct 2026

Returns an object's own properties as [key, value] pairs, in the same order as Object.keys(). Works for object literals, JSON data from documents, and Docly objects such as request.

See also: Object.keys

Parameters

Name Type Description
obj object

The object to read properties from.

Returns

An array of [key, value] arrays. For null or undefined, null (standard JavaScript throws a TypeError).

Example

Code example (JS)

JS is normal JavaScript either running in the browser or on the Docly™ server.
const stock = { apples: 12, pears: 0, plums: 5 };
Object.entries(stock).forEach(entry => {
    write(entry[0] + ": " + entry[1] + "\n");
});
/* Expected output:
apples: 12
pears: 0
plums: 5
*/

Output

The JS code above produces the output shown below:
apples: 12
pears: 0
plums: 5