Hash read/write/delete functions Here is my JavaScript function to manipulate the hash:

var hash = {
    get: function(key){
        var lh = location.hash;

        if(lh.charAt(0) === "#"){
            lh = lh.slice(1);
        }

        var pairs = lh.split("&amp;");
        var obj = [];
        for(var i = 0; i &lt; pairs.length; i++){
            var pair = pairs[i];
            if(pair.indexOf("=") &gt; 0){
                pair = pair.split("=");
                obj[pair[0]] = pair[1];
            }else{
                obj[pair] = 1;
            }
        }
        return typeof key !== 'undefined' ? obj[key] : obj;
    },
    set: function(key, value, cb){
        var newHash = this.removeKey(key);

        if(newHash.length &gt; 1){
            newHash += "&amp;";
        }
        newHash += key + (typeof value != 'undefined' ? "="+value : "");
        var url = location.href.split("#")[0] + (newHash !== "#" ? newHash : "");

        history.pushState(undefined, document.title, url);
        if(cb){
            cb();
        }
    },
    del: function(key){
        var newHash = this.removeKey(key);
        var url = location.href.split("#")[0] + (newHash !== "#" ? newHash : "");

        history.pushState(undefined, document.title, url);
    },
    removeKey: function(key){
        var string = location.hash;

        if(string.charAt(0) !== "#"){
            string = "#" + string;
        }

        var regex = new RegExp("[#&amp;]"+key+"(=[^&amp;]+|)", 'gi');
        string = string.replace(regex, "");

        if(string.charAt(0) === "&amp;"){
            string = "#" + string.slice(1);
        }

        return string !== '' ? string : '#';
    }
};


I am trying to make it as light as possible.
Streamlined code for get:

get: function(key){
    var lh = location.hash.replace(/^#/, "");
    var pairs = lh.split("&amp;");
    var obj = [], pair;

    for(var i = 0; i &lt; pairs.length; i++){
        pair = pairs[i].split("=");
        if (pair.length === 1) {
            pair.push(1);
        }
        obj[pair[0]] = pair[1];
    }
    return typeof key !== 'undefined' ? obj[key] : obj;
}, 


I also don't see why there's a callback passed to .set()?  There's no async operation and the callback is executed at the end of the function with no args so the caller could just put that same code right after the .set() call.  There doesn't seem to be any reason for a callback argument.