quote

Non-standard
This feature is non-standard and is not on a standards track. Do not use it on production sites facing the Web: it will not work for every user. There may also be large incompatibilities between implementations and the behavior may change in the future.

概述

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

Method of String
Implemented in JavaScript 1.3
ECMAScript Edition None

语法

str.quote()

示例

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

相关链接

Document Tags and Contributors

Contributors to this page: ziyunfei
Last updated by: ziyunfei,