Prevent Infinite Loops with a Valid Terminal Condition

On my mac both causing error when changing comparison operator


null is not an object (evaluating 'code.match(/i\s*?<=\s*?4;/g).length')


Cannot read property 'length' of null

string.match(regexp) returns null in case of no match.

So, whatever you wrote has a chance of becoming null.length, which is no no.

I don’t really know what your code is from what is shown; please, post the whole code for a better diagnosis.

I don’t use any regex at all, only the >= operator so this is a bug

Then, maybe whatever code parsing logic in those browsers might be functioning weird. Why don’t you post the full code? or more code to understand the context? Or full stack trace?

code.match(/i\s*?<=\s*?4;/g).length means the regex is looking for <= in between i and 4.