// Boolean expressions need to resolve to either true or false, as no
// implicit conversions are supported.
I'm sure they have good reason for this, does anyone know of the rationale? I think I'd miss patterns like `if (arr.length) { ... }`7,416 karma · joined October 23, 2009
Email: charles@codemix.com
// Boolean expressions need to resolve to either true or false, as no
// implicit conversions are supported.
I'm sure they have good reason for this, does anyone know of the rationale? I think I'd miss patterns like `if (arr.length) { ... }`UK, USA, Canada, Australia, New Zealand, Netherlands, Germany, Austria, all of Scandinavia
* edited to remove the word "most" which seems to be upsetting some people.
The problem is that spammers / extortionists can adapt their techniques much more so than Google can.
They care solely about getting paid, they don't care about building a brand, offering a good service or anything else. This allows them a huge degree of flexibility when finding ways to attack their less nimble adversary. They can transition from selling viagra to extortion with ease.
If it was straightforward, a company which employs many of the most gifted, technical minds in the world should probably have figured it out by now. Also, it's very unlikely that Pagerank is even in use at all at this point.
it's effectively the same input, but optimised for JSON.parse() rather than transit. This means it purely decodes into objects with fast properties (in V8 at least), so objects never have to undergo the -> hash table transition. It seems consistently faster, but you can argue that it's not doing quite the same thing.
fast-each [value] from arr {
}
fast-each {value} from obj {
}
fast-each [value, key] from arr {
}
fast-each {value, key} from obj {
}
The disadvantage is that this looks like array comprehension but isn't.Alternative:
fast-properties key, value from obj {
}
fast-elements index, value from arr {
}
fast-properties value from obj {
}
fast-elements value from arr {
} undefined = 'lol'; every element as key, value from arr {
console.log(key, value);
}
every property as key, value from obj {
console.log(key, value);
} var keys = Object.keys(obj),
length = keys.length,
key, i;
for (i = 0; i < length; i++) {
key = keys[i];
}
While this is not exactly the same as for..in, it usually behaves how you'd expect and is significantly faster for a couple of reasons:1. In a for..in loop the engine must keep track of the keys already iterated over, whereas in the fast version we can simply increment a counter and do a fast array lookup.
2. It's possible to add properties to the object that you're iterating within the body of the for..in statement, and these will be iterated too. Doing such a thing is obviously very rare but it's the kind of edge case the JS engine must keep track of.
function add (a, b) {
return a + b;
}
and this in C: int add(int a,int b)
{
return a + b;
}
you're going to get essentially the same performance.The latter sentence you quoted refers to the specific builtin functions that fast.js re-implements. So we first get close to native performance in JS, then we beat the builtin functions by doing less work overall.
The next step for fast.js are some sweet.js macros which will make writing for loops a bit nicer, because it's pretty painful to write this every time you want to iterate over an object:
var keys = Object.keys(obj),
length = keys.length,
key, i;
for (i = 0; i < length; i++) {
key = keys[i];
// ...
}
I'd rather write: every key of obj {
// ...
}
and have that expanded at compile time.Additionally there are some cases where you must use inline for loops (such as when slicing arguments objects, see https://github.com/petkaantonov/bluebird/wiki/Optimization-k...) and a function call is not possible. These can also be addressed with sweet.js macros.
for (i = 0, total = arr.length; i < total; i++) {
item = arr[i];
}
This will also iterate over gaps in the array. Is this a bug?