I have this sample function, and i want to call it in this format :
const myfunc = (string) => {
return string.length
}
console.log("check_length".myfunc())
How can i do that? Thanks for answers in advance!
I have this sample function, and i want to call it in this format :
const myfunc = (string) => {
return string.length
}
console.log("check_length".myfunc())
How can i do that? Thanks for answers in advance!
The only way is to mutate the prototype of String
with a classic function for accessing this
.
String.prototype.myfunc = function () {
return this.length;
};
console.log("check_length".myfunc());