Underscore.JS isRegExp方法 语法 _.isRegExp(object)JavaScriptCopy isRegExp方法用于检查对象是否是一个正则表达式。看下面的示例 – 示例 var _ = require('underscore'); //Example 1: Check if argument passed is a date console.log(_.isRegExp(/Sam/)); //Example 2: Check if argument passed is a date console.log(_.isRegExp('Sam'));JavaScriptCopy 将上述程序保存在 tester.js 中。运行以下命令以执行此程序。 命令 >node tester.jsJavaScriptCopy 输出 true falseJavaScriptCopy