static/ext/src/lang/Array.js
function(array, getKey, scope) {
            var map = {},
                i = array.length;

            if (!getKey) {
                while (i--) {
                    map[array[i]] = i+1;
                }
            } else if (typeof getKey == 'string') {
                while (i--) {
                    map[array[i][getKey]] = i+1;
                }
            } else {
                while (i--) {
                    map[getKey.call(scope, array[i])] = i+1;
                }
            }

            return map;
        }
function(array, getKey, scope) {
            var map = {},
                i = array.length;

            if (!getKey) {
                while (i--) {
                    map[array[i]] = i+1;
                }
            } else if (typeof getKey == 'string') {
                while (i--) {
                    map[array[i][getKey]] = i+1;
                }
            } else {
                while (i--) {
                    map[getKey.call(scope, array[i])] = i+1;
                }
            }

            return map;
        }
Creates a map (object) keyed by the elements of the given array. The values in
the map are the index+1 of the array element. For example:

var map = Ext.Array.toMap(['a','b','c']);

// map = { a: 1, b: 2, c: 3 };

Or a key property can be specified:

var map = Ext.Array.toMap([
{ name: 'a' },
{ name: 'b' },
{ name: 'c' }
], 'name');

// map = { a: 1, b: 2, c: 3 };

Lastly, a key extractor can be provided:

var map = Ext.Array.toMap([
{ name: 'a' },
{ name: 'b' },
{ name: 'c' }
], function (obj) { return obj.name.toUpperCase(); });

// map = { A: 1, B: 2, C: 3 };

@param {Array} array The Array to create the map from.
@param {String/Function} [getKey] Name of the object property to use
as a key or a function to extract the key.
@param {Object} [scope] Value of this inside callback.
@return {Object} The resulting map.