According to section 5.2.1 of this article: Optimization Killers
Doing this disables optimization in V8:
function hashTableIteration() {
var hashTable = {"-": 3};
for(var key in hashTable);
}
and the author says:
An object goes into hash table mode, for example, when you add too many properties dynamically (external constructor), delete properties, use properties that cannot be valid identifiers, etc. In other words, when you use an object as if it were a table hash, it will be turned into a hash table. Passing such an object to input-in is not. You can determine if an object is in hash table mode by invoking console.log(%HasFastProperties(obj))when the -allow-natives-syntax flag is enabled in Node.JS.
My question is, what is the correct way to iterate using the keys of a hash table object in javascript, so that the optimization doesn't turn off?
d - b source
share