For example
var contents = 'some text';
function fileSave(path){
// I'll handle saving the file, but I need the file contents
}
contents.fileSave('index.html');
So when the function is fun on the contents variable, the function has access to the variable. Like how replace() works in JavaScript.
EX.
str.replace();
but in this case
contents.fileSave();
the variable is interchangeable, the function applies to any variable is attached too.
Sorry, newbie..
If you want to add methods to all strings, you add it to
String.prototype.Just be aware of your environment. Extending the native prototypes could conflict with other code. You’ll need to decide for yourself if it’ll be an issue or not.