programming-examples/js/Vre2/Validate whether a given value is RegExp or not.js

10 lines
225 B
JavaScript
Raw Normal View History

2019-11-15 12:59:38 +01:00
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));