I try to add to the bottom of the object but it add to the top the object
The order of properties in an "ordinary" JavaScript object such as yours is set out by the specification. For the properties in your example, the 619
property comes first in that order, because it's an "array index" property name, those come before non-array index property names.
You can't change that, but more importantly, relying on object property order is almost always a bad idea. If you want order, use an array or a Map
. For instance, in your case, you might want a Map
, which is ordered purely by the order in which you add entries to it:
const map = new Map([
["Asf", 46],
["sage", 46],
["fdfds", 58],
]);
map.set("619", 48);
Live Example:
const map = new Map([
["Asf", 46],
["sage", 46],
["fdfds", 58],
]);
map.set("619", 48);
console.log([...map]);
.as-console-wrapper {
max-height: 100% !important;
}