Obsolete since Gecko 37 (Firefox 37 / Thunderbird 37 / SeaMonkey 2.34)
This feature is obsolete. Although it may still work in some browsers, its use is discouraged since it could be removed at any time. Try to avoid using it.

非标
此特征是非标准的,且不在标准轨道中。不要在面向 Web 的生产站点中使用它:它不适用于每个用户。实现之间可能存在大的不兼容性,且行为将来可能改变。

The non-standard quote() method returns a copy of the string, replacing various special characters in the string with their escape sequences and wrapping the result in double-quotes ( " ).

句法

str.quote()
					

返回值

A new string representing the original string wrapped in double-quotes, with any special characters escaped.

范例

Using quote

In the table below the quote() method replaces any special characters and wraps the strings in double-quotes. Also note the third column where a wrapped eval() evaluates the escape sequences again.

str str.quote() eval(str.quote())
Hello world! "Hello world!" Hello world!
Hello
world!
"Hello\n\tworld!" Hello
world!
" \ — ' "\" \\ \u2014 '" " \ — '

规范

Not part of any standard. Implemented in JavaScript 1.3.

浏览器兼容性

Not supported in any browser. Historically supported in Firefox 1 until 36.

另请参阅

元数据

  • 最后修改: