Step 5 of [ES5.1 - 15.10.6.2] RegExp.prototype.exec(string) must always be executed due to side effects. This affects not only plain calls to RegExp.prototype.exec, but also RegExp.prototype.test, String.prototype.match and String.prototype.replace, because these functions call directly or indirectly RegExp.prototype.exec. List of different javascript engines/browsers and the result for each test: --- r = /a/; r.lastIndex = {valueOf: function(){throw "err"}}; r.exec("zzzz"); Bad: JSC, IE Good: V8, SM, Opera r = /a/; r.lastIndex = {valueOf: function(){throw "err"}}; r.test("zzzz"); Bad: JSC, IE, Opera Good: V8, SM r = /a/; r.lastIndex = {valueOf: function(){throw "err"}}; "zzzz".match(r); Bad: JSC, IE, V8, SM Good: Opera r = /a/; r.lastIndex = {valueOf: function(){throw "err"}}; "zzzz".replace(r, ""); Bad: JSC, IE, V8, SM, Opera Good: - ---