RegExp.prototype only work for:
var a = /abc/g
a.tester()
var b = /xyz/
b.tester()
Doesn't work with:
/abc/g.tester()
/abc/.tester()
Is there a way I can fix this so all three can work?
Headsup
It needs to be a RegExp.prototype
Question: How does the native .test()
do it?
What Works
RegExp.prototype.tester = function(s, v) {
console.log("I'm working")
console.log(this)
}
a = /abc/g
b = /xyz/
a.tester()
b.tester()
Problems
RegExp.prototype.tester = function(s, v) {
console.log("I'm working")
console.log(this)
}
/abc/g.tester() //This is a problem
/abc/.tester() //This is a problem