I am practicing code readability and "beautifying" my code, so I want to learn how to implement this.
I've seen other code do this, but I don't remember which or how they did it.
I want to create my own .string functions, like so:
var rmbrackets = new function() {
return String.replace(/\[.*?\]/g, "");
}
console.log("this is a [test]test!".rmbrackets);
I want the above to log "this is a test!". The above is just an example, I want to do this with many other functions.
How can i do this?
"foo".rmbrackets(), unlike Ruby. Without the parens, you are grabbing the reference to the function instead.