-2

enter image description here

I want to start it from NV to 1952

JanCarlo
  • 1
  • 2
  • You shouldn't care about the order of object entries. Perhaps you want to use a `Map` instead. – Unmitigated Mar 11 '23 at 08:36
  • It's impossible. Numeric properties will always come before alphanumeric properties – Andrew Parks Mar 11 '23 at 10:31
  • Does this answer your question? [Does ES6 introduce a well-defined order of enumeration for object properties?](https://stackoverflow.com/questions/30076219/does-es6-introduce-a-well-defined-order-of-enumeration-for-object-properties) – Andrew Parks Mar 11 '23 at 10:49

2 Answers2

0

You can use Object.keys and reverse method.

Object.keys(object)
  .reverse()
  .forEach((item) => {
    console.log(item, ":", object[item]);
  });
Meer Humza
  • 49
  • 1
0

Basically, it doesn't make any sense to reverse objects as objects are not in order.

    let dummyObj = {a: 1, b: 2, c: 3};
    let entries = Object.entries(dummyObj );
    let reversedEntries = entries.reverse();
    let reversedObj = Object.fromEntries(reversedEntries);
    console.log(reversedObj);
Andrew Parks
  • 6,358
  • 2
  • 12
  • 27
  • Object properties are ordered, and you can change the order. The code you wrote in your answer proves it. But, there is a rule that numeric property names must always come first and appear in numeric order, and you cannot change that – Andrew Parks Mar 11 '23 at 10:37