3 ms·
I disagree. I think fault lies with the language designer(s) for putting the equivalent of a pull-handle on a push-door. The only way to reliably avoid this err
by ggreer 12y ago
I disagree. I think fault lies with the language designer(s) for putting the equivalent of a pull-handle on a push-door. The only way to reliably avoid this error would be to spend an inordinate amount of time reading documentation, dutifully examining every aspect of basic functionality for unusual behavior. Every other string replace method I've encountered does global replace. Java's String.replace(), STL's std::replace, PHP's str_replace, Python's string.replace(), all of them replace every instance. Given this precedence, it's entirely reasonable to assume JavaScript works the same. Unfortunately, it doesn't.
I've been writing JavaScript off-and-on since I was 12. I've used Node.js extensively enough to find bugs in it, including one that ended up being a bug in V8[1][2]. If I'm not an experienced JavaScript developer, then very few are.
1. http://geoff.greer.fm/2012/05/30/leaky-abstractions-a-journey-into-mordor/ http://geoff.greer.fm/2012/05/30/leaky-abstractions-a-journe...
2. https://github.com/joyent/node/issues/3167 https://github.com/joyent/node/issues/3167