C # has an amazing syntax function, where for a function that expects a delegate type, you can pass a "group of methods", for example:
"string".Count (Char.IsWhiteSpace);
and not (relatively speaking) noise:
"string".Count (c => Char.IsWhiteSpace (c));
(Edit: best example).
I would like to do something similar in Javascript, which has a much more noisy syntax for anonymous functions:
var name = "foobar".replace (/^\w/, function (c) { return c.toUpperCase (); });
I played with various attempts and permutations of arguments in functional form String.prototype.replaceusing calland apply, but the string argument passed in ( cin the above example) is apparently not thisin the area inside toUpperCase(at best, I get less useful DOMWINDOWoobarand TypeErrorat worst).
, , , , - , ?