views:

134

answers:

1

I've been messing around with string.replace and I noticed something very odd with Webkit and Firebug's javascript consoles.

I can repeat this behavior in a blank browser window. (Look at the first and last lines)

>>> "/literature?page=".replace(/page=/i, "page=2")
"/literature?page="

>>> "/literature?page=".replace("page=", "page=2")
"/literature?page=2"

>>> "/literature?page=".replace(/page=/, "page=2")
"/literature?page=2"

>>> "/literature?page=".replace(/page=/i, "page=2")
"/literature?page=2"

Just so nobody thinks I mistyped something, here are screenshots.

Firebug (3.0.14)

firefbug

Webkit (Latest nightly as of this post's creation.)

webkit

A: 

In Google Chrome I get the final result the first time. See the image here.

Jared Forsyth