DEV Community

mhsohag11
mhsohag11

Posted on

1

Answer: How to prevent automatic sort of Object numeric property?

The simplest and the best way to preserve the order of the keys in the array obtained by Object.keys() is to manipulate the Object keys a little bit.

insert a "_" in front of every key name. then run the following code!

myObject = {
  _a: 1,
  _1:

Top comments (0)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay