Simple way to map anything to anything.

Kind of a hash map.

by Oliver Caldwell

JavaScript

var aliases = {};

function User(name) {
    this._name = name;
}
User.prototype.toString = function() {
    // You could probably use some kind of UID instead.
    // It just has to be a unique identifier of any kind.
    return this.constructor.name + ':' + this._name;
};

var someUser = new User('Oliver Caldwell');
aliases[someUser] = 'Wolfy87';

console.log(aliases);