On Thu, Jul 11, 2013 at 5:02 PM, Brandon Benvie <[email protected]> wrote:
>
> // ES6
> function* entries(obj){
> for (let key in obj) {
> yield [key, obj[key]];
> }
> }
>
cool, but why do we need that exactly ?
>
> // ES3-5 version
> function entries(obj){
> var keys = [];
> var index = 0;
> for (keys[index++] in obj);
> var total = index;
> index = 0;
> return {
> next: function(){
> if (index < total) {
> var key = keys[index++];
> return { done: false, value: [key, obj[key]] }
> }
> return { done: true };
> }
> };
> }
have you guys read this article ? where it talks about JS people not
thinking about GC and RAM ?
http://sealedabstract.com/rants/why-mobile-web-apps-are-slow/
Thanks for this perfect example of (IMO) not-needed thing to just have
key/value pairs ... is this the new ES direction? `Objkect.keys(obj)` ain't
cool anymore because we can (metaphorically, I know it won't work)
`for(yield key in obj);` ?
These kind of things are one of the reason old HW and mobile is slow, we
keep penalizing for no concrete reason already slow engines under limited
hardware proposing not so useful, in this very specific case, solutions to
simple problems.
Personally, I don't like that (I know you could not care more about this)
but I don't think is good for anyone or anything in any case ... really, I
don't see any reason to have that anywhere at all in first place, even in 5
years with generators/iterators available everywhere.
One thing I liked though, you showed a trick over for/in I've never thought
about but you didn't consider in ES3 everyone would have to check for
hasOwnProperty too ... so that could have been simplified with
`Object.keys(obj)` in ES3 polyfilled out of ES5.
Back to Rick ... yes, polyfills cannot decide the future ... I've also read
once here that new stuff should not have broken old one, this is what I
really liked about asm.js and what I don't understand about all this
generator fuzz out of python 2.2 or similar 2000ish problems/programming
languages.
Just my opinion, sorry about that.
Best Regards
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss