--- title: RegExp.prototype.toSource() slug: Web/JavaScript/Reference/Global_Objects/RegExp/toSource tags: - JavaScript - Method - Non-standard - Prototype - RegExp translation_of: Web/JavaScript/Reference/Global_Objects/RegExp/toSource ---

{{JSRef("Global_Objects", "RegExp")}}{{ Non-standard_header() }}

概述

返回一个字符串,代表当前对象的源代码

语法

regexObj.toSource()

描述

toSource方法返回值如下:

function RegExp() {
    [native code]
}

该方法通常由JavaScript内部隐含调用,而不会明确的出现在用户代码中.

相关链接

Object.prototype.toSource