In javascript tutorial I’ve see the next object definition:
var myObject = {
validIdentifier: 123,
'some string': 456,
99999: 789
};
What the purpose of such key-value pairs with quoted ones as keys? How one could operate with such values?
You can access them with brackets (called “bracket notation” or the “subscript operator”):
Keys like this must to be quoted because of the space (to avoid syntax errors).
The reasons for doing this are up to the developer. One (of like, a million) examples would be
Backbone.js‘sdelegateEventsthat maps events and selectors to handler functions.