I'm trying to learn how to add new methods in the String.prototype in JavaScript. But I can't figure out a way on how to access the string specified in the new method:
String.prototype.new_method = function(){ THE_STRING; };
So that it will return "abc" when I call it:
"abc".new_method();
I know this can easily be done by doing:
function returnstring(str){
return str;
}
But I really want to learn how prototypes in JavaScript works.