JavaScript Object.entries() Method

Beginner
5 min read
Updated: Nov 2026
3 examples
Object

Definition

Object.entries(obj) returns an array of pairs. Each pair is [key, value] for one own enumerable string-keyed property.

Use it when you want to loop keys and values together, filter pairs, or pass the result to Object.fromEntries().

Syntax

Call Object.entries() like this. Start with this line.

JavaScript
Object.entries(obj)
CallWhat it does
Object.entries(obj)Returns [[key, value], ...] for obj's own enumerable string keys.

Built into JavaScript. Call on Object — no import required.

Library declarations
JavaScript
Object.entries(obj)
JavaScript
entries(o: object): [string, any][];

Parameters

ParameterDescription
objRequired. The object to read. Non-object values are converted to objects first.

Return Value

Return ValueDescription
arrayAn array of [key, value] arrays, in the same order as Object.keys().

JavaScript Examples

Example 1 — Basic Use

Get every own enumerable key and value as pairs.

JavaScript
var user = { name: "Riya", age: 22, city: "Pune" };

console.log(JSON.stringify(Object.entries(user)));
// [["name","Riya"],["age",22],["city","Pune"]]
Try It Yourself

How It Works

  1. Read the object. user has three own enumerable properties.
  2. Build pairs. Each property becomes a two-item array: key then value.
  3. Order matches keys. The pair order matches Object.keys(user).

Example 2 — Loop Pairs

Walk each [key, value] pair with forEach.

JavaScript
var user = { name: "Riya", age: 22, city: "Pune" };

Object.entries(user).forEach(function (pair) {
  console.log(pair[0] + "=" + pair[1]);
});
// name=Riya
// age=22
// city=Pune
Try It Yourself

How It Works

  1. Get the list. Object.entries(user) returns the pairs array.
  2. Read each pair. pair[0] is the key and pair[1] is the value.
  3. Print a line. Each property prints as key=value.

Example 3 — Sum Values

Use entries when you need the values while looping.

JavaScript
var scores = { math: 90, science: 85 };
var total = 0;

Object.entries(scores).forEach(function (pair) {
  total += pair[1];
});

console.log(total);  // 175
Try It Yourself

How It Works

  1. Start at zero. total will hold the running sum.
  2. Add each value. For every pair, add pair[1] to total.
  3. Final sum. 90 + 85 is 175.

Browser & Runtime Support

Object.entries() arrived in ES2017 and is Baseline Widely available in modern browsers and Node.js.

✓ Baseline · ES2017

Object.entries()

Supported in Chrome 54+, Firefox 47+, Safari 10.1+, Edge 14+, and Node.js 7+. Safe for modern apps.

97% Modern browser support
Google Chrome Supported · Desktop & Mobile
Full support
Mozilla Firefox Supported · Desktop & Mobile
Full support
Apple Safari Supported · macOS & iOS
Full support
Microsoft Edge Supported · Chromium
Full support
Internet Explorer No native support · Use a polyfill
Polyfill
Opera Supported · Modern versions
Full support
Samsung Internet Supported · Android
Full support
Bun Supported · JavaScript runtime
Supported
Deno Supported · JavaScript runtime
Supported
Node.js Supported · Server runtime
Supported
Android WebView Supported · Modern WebView
Full support
Object.entries Excellent

Bottom line: Use Object.entries() in modern browsers. Very old engines need a polyfill.

Frequently Asked Questions

It returns an array of [key, value] pairs for an object's own enumerable string-keyed properties.
keys() returns only names. values() returns only values. entries() returns both together as pairs.
No. Only own enumerable properties are included. Inherited ones are skipped.
No. Object.entries() only includes string keys. Use Object.getOwnPropertySymbols() for symbol keys.
Yes. Pass the pairs to Object.fromEntries() to rebuild an object.

Next: freeze()

Lock an object so its properties cannot change.

freeze() tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

8 people found this page helpful