1 2 3 4 5 6 7 8 9 10
function test() { var a = ['x', '', '', '', '', '', '', 'x']; var b = ''; for (var i = 0; i < a.length; i++) { (function() { a[i].replace(/x/, function() { return b; }); }()); } } test(); // should NOT get a ReferenceError for b on trace