Possible duplicate:
typeof for RegExp
I have a procedure that checks if an object meets the given criteria.
testForMatch(objectToTest, matchCriteria) { // all my testing logic here. }
The matchCriteria
parameter is an object that might look like this:
{ 'size' : "large", 'color' : /(blue|red)/ }
This matchCriteria
in the above example will be used to check whether the objectToTest
has a objectToTest
attribute with a value of "large"
and a color
attribute with a value of either "blue"
or "red"
.
So matchCriteria
has the property / attribute names that will be searched in objectToTest
for the purpose of matching property values. Or, if a regular expression is specified as the value (as is the case with color
above), the property in objectToTest
will have the value RegExp.test()
for the given regular expression.
But in order to correctly examine matchCriteria
in testForMatch()
I need to determine if the attribute value in matchCriteria
string or a RegExp
object.
My question is how to determine if the value of the RegExp
attribute is an object?
source share