Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

String.prototype.quote()

已废弃 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.

非标准
该特性是非标准的,请尽量不要在生产环境中使用它!

概述

将字符串中包含的特殊字符进行转义(反斜杠),然后在字符串两边各加上一个双引号(")并返回,并不修改原字符串.

语法

str.quote()

示例

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

规范

不在任何规范中。实现于 JavaScript 1.3.

浏览器兼容性

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support 未实现 未实现 未实现 未实现 未实现
Feature Android Chrome for Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support 未实现 未实现 未实现 未实现 未实现 未实现

相关链接

文档标签和贡献者

 此页面的贡献者: teoli, tiansh, ziyunfei
 最后编辑者: teoli,