1 comment

[ 2.2 ms ] story [ 9.6 ms ] thread
I wonder if it would be quicker for getHash() to check for object (including functions) first, then for string, then let the rest come as they are, more or less:

    var objectId = 1000000;

    function getHash2(value) {
        if (typeof value === 'object' || typeof value === 'function') {
            if (value === null)
                return 'null';
            value._hash = value._hash || ('[object ' + (objectId++) + ']');
            return value._hash;
        }
        return typeof value === 'string' ? "'" + value : value
    }