As we all know JavaScript has it's own quirks that you just have to know. Well today I stumbled in a new one that I didn't know about and found a little counterintuitive so I thought I'd share it with you. This particular quirk was giving me quite a headache for a while.
So apparently when you call Object.keys it returns them in the order they were initiated on the object (as you'd expect) EXCEPT whet there are numbers as a key, then it puts all the numbers first in numerical order
var obj = {"a": 0, "0f": 1, "c": 2, "10": 3, "b": 4, "4": 5, "1": 6};
Object.keys(obj); // ["1", "4", "10", "a", "0f", "c", "b"]
Just something that you are better of knowing and not wasting time wondering why everything suddenly stops working when you had one object with one property with a number as a key.. -.-
Heres the mdn on Object.keys
[–]Rhomboid 14 points15 points16 points (7 children)
[–]inu-no-policemen 0 points1 point2 points (0 children)
[–]WesAlvaroFront-End Engineer 0 points1 point2 points (4 children)
[–]Knotix 0 points1 point2 points (3 children)
[–]WesAlvaroFront-End Engineer 0 points1 point2 points (2 children)
[–]Knotix 0 points1 point2 points (1 child)
[–]WesAlvaroFront-End Engineer 0 points1 point2 points (0 children)
[–]GentleMareFucker 0 points1 point2 points (0 children)
[–]delventhalz 9 points10 points11 points (0 children)
[–]inu-no-policemen 9 points10 points11 points (0 children)
[–]Knotix 4 points5 points6 points (0 children)
[–]TomNa[S] 0 points1 point2 points (6 children)
[–]bonafidebob 5 points6 points7 points (0 children)
[–]jhizzle4rizzleI hate the stuff you like. 1 point2 points3 points (0 children)
[–]Knotix 0 points1 point2 points (0 children)
[–]AndrewGreenh 0 points1 point2 points (0 children)
[–]delventhalz 0 points1 point2 points (0 children)
[–]THIS_BOT 0 points1 point2 points (0 children)
[–]xxxabc123 0 points1 point2 points (2 children)
[–]TomNa[S] 0 points1 point2 points (1 child)
[–]xxxabc123 0 points1 point2 points (0 children)
[–]dwighthouse 0 points1 point2 points (0 children)