'0101'.replace('0', function(){return 1}) == '1101'

so your last two are the same:

replace(string, callback) -> called one time, using the first indexOf and
replacing it invoking the callback
replace(string, string) -> called one time, using the first indexOf and
replacing it via provided string and checking $



On Mon, Jul 28, 2014 at 10:29 PM, Christoph Martens <cmarten...@gmail.com>
wrote:

>  On 28.07.2014 17:24, Rick Waldron wrote:
>
>
>
>
> On Mon, Jul 28, 2014 at 11:16 AM, Boris Zbarsky <bzbar...@mit.edu> wrote:
>
>> On 7/28/14, 11:09 AM, Rick Waldron wrote:
>>
>>>    var y = x.replace('{{blob}}', function() {
>>>      return data;
>>>    });
>>>
>>
>>  In fairness, that's the sort of thing that gives off a "WAT smell". Code
>> like this without a comment that explains the indirection is just asking
>> someone to "simplify" it, breaking it in the process...
>
>
>  I don't disagree with your feedback, but JS has had special semantics
> for "$" (with ’ or n) character in the replaceValue since ES3 (just short
> of 15 years). I didn't say that the solution was obvious, just that it
> required familiarity ;)
>
>  Rick
>
>
> _______________________________________________
> es-discuss mailing 
> listes-discuss@mozilla.orghttps://mail.mozilla.org/listinfo/es-discuss
>
>
> Hey Rick,
>
> To be honest, I didn't know the trick with the dummy filter function
> returning the plain data. I expected that it was executed each time a match
> was found (similar to Array filter functions).
>
> I think for external guys writing JavaScript, the WAT effect is pretty
> huge. Either we should change the behaviour of the parameters (which is bad
> for legacy implementations) or the flags to disable it optionally.
>
> As I wasn't familiar with the replace behaviour before, I would expect the
> method to behave differently, depending on the arguments:
>
>
> replace(regexp, string) -> parse string and see if $ is in there
> replace(regexp, callback) -> callback is called each time regexp is matched
> replace(string, callback) -> only called once
> replace(string, string) -> called one time, using the first indexOf and
> replacing it
>
>
> ~Chris
>
>
> _______________________________________________
> es-discuss mailing list
> es-discuss@mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>
>
_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to