Underscore.JS - isRegExp 方法
语法
_.isRegExp(object)
isRegExp 方法检查对象是否为正则表达式。请参阅以下示例 −
示例
var _ = require('underscore'); //示例 1:检查传递的参数是否为日期 console.log(_.isRegExp(/Sam/)); //示例 2:检查传递的参数是否为日期 console.log(_.isRegExp('Sam'));
将上述程序保存在tester.js中。运行以下命令执行该程序。
命令
\>node tester.js
输出
true false
underscorejs_comparing_objects.html