I'm working with a Backbone project, and in our router we specify a default route at the end of the routes
property:
routes: {
"things": "stuff",
"*actions": "default"
}
From a bit of searching around, I've seen a couple of places, such as this StackOverflow answer and the Backbone tutorial, which suggest adding a default route this way.
However, this deeply concerns me, because from what I can see in the Backbone source, the routes
property is simply iterated over to add all the routes in it, and to the best of my knowledge, object iteration in JavaScript doesn't guarantee any ordering. Therefore, with the above routes
definition, it's not guaranteed that the default route has lowest precedence just by virtue of being at the end of the definition.
Is the behavior essentially undefined here, and things are actually working out just a matter of pure luck, or is there something else going on that actually makes this a safe thing to do?