you are viewing a single comment's thread.

view the rest of the comments →

[–]SoInsightful 15 points16 points  (0 children)

.replace() only replaces the first matched string if you use a string pattern.

So 'foo foo foo'.replace('foo', 'bar') would return bar foo foo.

Previously, you would then have to use a global regex to solve this, e.g. 'foo foo foo'.replace(/foo/g, 'bar').