I want to define a property on the string constructor, and I want then to access this property from any file in my project. for example:
file1.js
String.capitalize = function(){
this.//...etc
}
file2.js
"Hello nice to meet you".capitalize()
I want to define a property on the string constructor, and I want then to access this property from any file in my project. for example:
file1.js
String.capitalize = function(){
this.//...etc
}
file2.js
"Hello nice to meet you".capitalize()
You can define a new String prototype function like in the example below
String.prototype.capitalize = function(){
return this.toUpperCase();
};
console.log("Hello nice to meet you".capitalize());