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()

This article needs an editorial review. How you can help.

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.

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.

El mètode no estàndard quote() retorna una còpia de la cadena, reemplaçant diferents caràcters especials de la cadena amb les seves seqüències d'escapament i embolcalla el resultat amb cometes dobles (").

Sintaxi

str.quote()

Exemples

A la taula següent, el mètode quote() reemplaça els caràcters especials i embolcalla les cadenes amb cometes dobles.  Tingueu en compte que en la tercera on un eval() embolcallat avalua la seqüència d'escapament novament.

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

Especificacions

No forma part de cap estàndard. Implementant en JavaScript 1.3.

Compatibilitat amb navegadors

Característica Chrome Firefox (Gecko) Internet Explorer Opera Safari
Suport bàsic Not supported Not supported Not supported Not supported Not supported
Característica Android Chrome per Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Suport bàsic Not supported Not supported Not supported Not supported Not supported Not supported

Vegeu també

Document Tags and Contributors

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