Nidiffer: Nored implementing every by using reduce
Nored: Nidiffer: that sounds like an approach instead of an actual problem
Nidiffer: Nored and that’s exactly what it is
Shahinian: Nidiffer: http://jsfiddle.net/zbqgo05h/ ?
Nored: Nidiffer: what are you writing this code for?
Nored: What is this code supposed to do? I am guess you are not going back to the client/business owner and telling them every/reduce
Bodrey: Let every = function list, predicate { return list.reducefunction res, ele { return res && predicateele; }, true; };
Nidiffer: Rcyr damn, now I gotta figure out how all that worked out like that, thanks for that:
Nidiffer: Nored practicing underbar.js
Croasmun: Nidiffer: If you aren’t using the first variable in a reduce, you’re probably not going to do what you are trying to do.
Nidiffer: Rcyr yeah, that indeed works with my code, thanks a lot for that: Havvy and yours work as well, thank you too
Nidiffer: Havvy aha, that’s how I figured that Im not utilizing it properly
Feenstra: You can implement forEach, but that’s about it.
Bois: Anyone know a good html parsin lib
Columbres: Are you guys able to see this?
Nidiffer: Rcyr Havvy I’ve also seen this implementation, is this any better or it’s just the same thing done differently?of course aside from length check and all that stuff Im talking about just core reduce part of it? http://jsfiddle.net/kcnpffrj/
Mihalick: Alright I’m looking for the best strategy when it comes to requesting for new data from the server every 15 seconds.
Nidiffer: Rcyr doesn’t this implementation look kinda strange?
Laureno: Nidiffer: It’s the same thing, except that it is polymorphic in that if you don’t p*** a predicate, it ***umes that you are just testing if every value is truthy.
Maida: I guess I am missing a Boolean cast in my snippet though.
Nidiffer: Ahh, alright I figured! it just has this case if no callback is provided it gonna take true as its initial value, right Havvy ?
Bran: Every takes true as a default value no matter what.
Staiger: Every, function { return false; } = true
Nidiffer: Ah, got it: thanks whole a lot Havvy
Dickman: Let every = function list, predicate { return list.reducefunction res, ele { return res && Booleanpredicateele; }, true; };
Janicki: Let some = function list, predicate { return list.reducefunction res, ele { return res Booleanpredicateele; }, false; };
Tumulty: That won’t break early tho, like real some/every will.
Bussler: Yeah, you can’t use reduce if you care about performance of some & every.
Truscott: If only there was a reduce.breakres we could return that would make it return early.
Brocker: I’m serious about that
Gearing: I know, that’s why i’m laughing.
Riederer: Of course, that line of thinking gets you close to reducers.
Nidiffer: Havvy lol this is a practice from underbar that’s why Im doing it :p this is a good practice, but I just realized a problem, when no callback is p***ed, it doesn’t return neither true of false, it just returns the last element from the array :-/
Houchard: Nidiffer: That’s because it’s not casting to Boolean when no callback is given.
Yokel: Should be Booleanres && item in their code.
Banasiak: Though they’d likely write it as !res && item because they like their !s.
Layland: Does jsonp request follow 302 redirects?
Nidiffer: Havvy absodamnlutely you are right: it works now
Nidiffer: Havvy Boolean and ! would do the same thing in this scenario?
Kounkel: Nidiffer: They are always equivalent.
Balbi: Function ! value { if Booleanvalue { return false; } else { return true; } }
Nidiffer: Havvy I didn’t know there could be double bangs together :