javascript - why String.prototype.replace process first match only? -


i'm sure know "some string".replace("s", "") strips first "s" occurence reason?

can give me input on internal logic of this? i've failed find out @ emca specs mean every decision should have motivation part , important me understand reason.

the reason works way right there in spec:

if searchvalue not regular expression, let searchstring tostring(searchvalue) , search string first occurrence of searchstring. let m 0.

the spec says first occurrence, not each occurrence.


Comments