Please tell me how can I use the injected functions in predefined variables. Here's the script to convert a string into camel case, but I don't know how to use it.
String.prototype.toCamelCase = function(str) {
return str
.replace(/\s(.)/g, function($1) { return $1.toUpperCase(); })
.replace(/\s/g, '')
.replace(/^(.)/, function($1) { return $1.toLowerCase(); });
}
Also, tell me if there is any relevancy of using $1
as the arguments! I mean is there any use of $
in this function?
P.S. I took this script from this question.