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:<p><pre><code> 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
}</code></pre>