can you re-parenthesize this to 

    (i !== null && !isNaN(i)) ? Math.max(0, Math.min(len, i)) : len;

I always have to look up precedence levels when dealing with && and ? : operators, so without them, this is harder to read.