Here you can find the source of quote()
// Taken from "Remedial Javascript" by Douglas Crockford: // http://javascript.crockford.com/remedial.html String.prototype.quote = function () { var c, i, l = this.length, o = '"'; for (i = 0; i < l; i += 1) { c = this.charAt(i);/*from w w w.ja v a 2s . c o m*/ if (c >= ' ') { if (c === '\\' || c === '"') { o += '\\'; } o += c; } else { switch (c) { case '\b': o += '\\b'; break; case '\f': o += '\\f'; break; case '\n': o += '\\n'; break; case '\r': o += '\\r'; break; case '\t': o += '\\t'; break; default: c = c.charCodeAt(); o += '\\u00' + Math.floor(c / 16).toString(16) + (c % 16).toString(16); } } } return o + '"'; };
String.prototype.dequote = function() { return this.replace(/^"|"$/g, '');
String.prototype.quote = (function(){ return '"' + this + '"'; })
String.prototype.quote = function(sym) { if (!sym) { sym = '"'; return sym + this + sym; };