News for hackers. Stuff that matters.
Re:Top 5 MongoDB gotchas by BuzzKilla1960 on Tuesday January 07, 2014 @06:00PM (#7020614)
Wouldn't the simpler, faster and more appropriate syntax be

if (N > 50 || N < 1) ??

Re:Top 5 MongoDB gotchas by BerislavLopac on Tuesday January 07, 2014 @08:05PM (#7021068)
No it wouldn't, because -30 is supposed to work the same as 30, so you want to convert the sign to positive first. Personally, I'd use something like:

    if (!N || Math.abs(N) > 50 ) {
        N = 50
    };
Re:Top 5 MongoDB gotchas by imslavko on Tuesday January 07, 2014 @06:04PM (#7020631)
It would be a simpler and shorter piece of code. Not sure why it would be faster though. Anyways, the point was in the behavior of `limit` which is easy to miss.
Re:Top 5 MongoDB gotchas by angersock on Tuesday January 07, 2014 @06:04PM (#7020629)
I think they may be trying something clever with the truthiness of N there...