programming-examples/js/Vre2/Validate whether a given value is RegExp or not.js
2019-11-15 12:59:38 +01:00

10 lines
225 B
JavaScript

function is_regexp(value)
{
return toString.call(value) === '[object RegExp]';
}
console.log(is_regexp(/test/));
console.log(is_regexp('bar'));
console.log(is_regexp(72));