javascript - In which browsers are regular expression literals created only once -
i'm reading through javascript patterns book, , 1 of examples regarding creation of regular expression literals not appear consistent chrome version 36.0.1985.125 on mac osx.
here's example
function getre() { var re = /[a-z]/; re.foo = "bar"; return re; } var reg = getre(), re2 = getre(); console.log(reg === re2); //true according book reg.foo = "baz"; console.log(re2.foo); //baz according book in version of chrome, line 1 in console false, , line 2 still "bar"
they go on in es5 literal create new objects each time. version of chrome implement es5? , if so, thought browsers still on 3 minus few augmentations.
Comments
Post a Comment