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
.
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.