For example, I would like to do something like this:
var t = /^foo(bar)?$/i; alert(typeof t); //I want this to return "regexp"
Is this possible?
EDIT: Thanks for all the answers. It seems I have two very good choices:
obj.constructor.name === "RegExp"
obj instanceof RegExp
Any major pros/cons to either method?
you can use instanceof operator:
var t = /^foo(bar)?$/i; alert(t instanceof RegExp);//returns true
In fact, that is the same as:
var t = /^foo(bar)?$/i; alert(t.constructor == RegExp);//returns true