DEV Community

loading...

Object keys are stored in insertion order

318097 profile image Mehul Lakhanpal Originally published at codedrops.tech ・1 min read
const obj = {
  name: "Human",
  age: 0,
  address: "Earth",
  profession: "Coder",
};

console.log(Object.keys(obj)); // name, age, address, profession
Enter fullscreen mode Exit fullscreen mode

Objects maintain the order in which the keys were created.


Thanks for reading 💙

Follow @codedrops.tech for daily posts.

InstagramTwitterFacebook

Micro-Learning ● Web Development ● Javascript ● MERN stack ● Javascript

codedrops.tech

Discussion (1)

pic
Editor guide
Collapse
yousaf profile image
Yousaf

ES6 defines standard rules for the order of properties in an object. See this stackoverflow question to understand the order of properties in an object.