Difference between Object.keys() and Object.entries() methods in JavaScript Last Updated : 24 Jun, 2024 Summarize Comments Improve Suggest changes Share Like Article Like Report Object.keys() and Object.entries() are methods in JavaScript used to iterate over the properties of an object. They differ in how they provide access to object properties: Object.keys() returns an array of a given object's own enumerable property names, while Object.entries() returns an array of a given object's own enumerable string-keyed property [key, value] pairs. Table of Content Object.keys()Object.entries()Object.keys()Object.keys() iterates over an object's own enumerable properties, returning an array containing the keys of those properties. Example: To demonstrate the implementation of the Object.Keys() method in JavaScript. JavaScript const obj = { name: 'John', age: 30, city: 'New York' }; const keys = Object.keys(obj); console.log(keys); Output[ 'name', 'age', 'city' ] Object.entries()Object.entries() iterates over an object's own enumerable string-keyed property [key, value] pairs, returning an array of arrays. Example: To demonstrate the implementation of the Object.entries() method in JavaScript. JavaScript const obj = { name: 'John', age: 30, city: 'New York' }; const entries = Object.entries(obj); console.log(entries); Output[ [ 'name', 'John' ], [ 'age', 30 ], [ 'city', 'New York' ] ] Difference between Object.keys() and Object.entries()Features Object.keys() Object.entries() Return Value Array of object's keys Array of [key, value] pairs Iteration Output Returns keys as strings Returns [key, value] pairs as arrays Use Case Useful for iterating over keys Useful for iterating over [key, value] pairs Example Output `["name", "age", "city"]` `[["name", "John"], ["age", 30], ["city", "New York"]]` Comment More infoAdvertise with us Next Article Difference between Object.keys() and Object.entries() methods in JavaScript S SHUBHAMSINGH10 Follow Improve Article Tags : JavaScript Web Technologies JavaScript-Misc JavaScript-Questions Similar Reads Difference Between Object.keys() and Object.getOwnPropertyNames() in JavaScript In JavaScript, Object.keys() and Object.getOwnPropertyNames() both retrieve properties of an object but differ in scope. Object.keys() returns an array of an object's own enumerable property names. In contrast, Object.getOwnPropertyNames() returns an array of all own property names, including non-en 2 min read Difference Between for...in and Object.keys() in JavaScript The for...in and Object.keys() in JavaScript are used to iterate over the properties of an object. While they might seem similar at first glance they have distinct usage, behavior, and characteristics. This article will explore these differences in detail.These are the following topics that we are g 3 min read Difference Between Variables and Objects in JavaScript The variables and objects are fundamental concepts but they serve different purposes. The Variables are used to store data values while objects are used to group related data and functions into a single entity. JavaScript VariableA variable in JavaScript is a named container that stores a value. It 2 min read Difference Between Objects and Prototypes in JavaScript Objects in JavaScriptThe Objects in JavaScript are instances of the class or constructors and they can hold properties and methods. These properties and methods can be unique to the object or inherited from the prototypes. The Objects can be created using the constructor functions, object literals, 3 min read Difference between Array and Array of Objects in JavaScript ArrayAn Array is a collection of data and a data structure that is stored in a sequence of memory locations. One can access the elements of an array by calling the index number such as 0, 1, 2, 3, ..., etc. The array can store data types like Integer, Float, String, and Boolean all the primitive dat 3 min read Like