function f() { var re1 = /0/, re2 = new RegExp('0'); alert([re1.foo, re2.foo]); re1.foo = 1; re2.foo = 1; } f(); f();