4 ms·
Show HN: Sets in JavaScript
- cynwoody 14y agoI 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 }