educative.io

Javascript Catch: Object.keys will return in order of insertion for alphabets

It’s important to note that inDegree is used as object

And when we do Object.keys(), the order of sources would be that of insertion in inDegree.

Generally Object.keys() doesn’t return ordered value by specs.
But it does in order of insertion in this case.
It won’t work if alien dictionary contains numbers in future

Source: https://stackoverflow.com/a/23202095/2174742

Cheers