Reputation: 319
Here is a snippet to explain my question:
+function(str) {
return str.replace(/^[a-z]|\s[a-z]/g,
Function.call.bind(String.prototype.toUpperCase));
}('foo bar baz.'); //Returns Foo Bar Baz.
Function.call
works, but String.toUpperCase
does not. I have to instead write, String.prototype.toUpperCase
.
Upvotes: 2
Views: 94
Reputation: 413826
The Function()
constructor is itself a function. Therefore, it inherits from the same prototype object as any other function.
Instances of String()
inherit from the prototype, but the String()
constructor is not an instance of String()
. It too is a function.
Upvotes: 8