Nodejs String Quote quote(sym)

Here you can find the source of quote(sym)

Method Source Code

/**/*  w ww .j a  va2s.c  o  m*/
 * Quotes a string with a starting and ending symbol.
 * @param sym Symbol. If not defined, quotes " are used.
 * @returns {string} Quoted string.
 */
String.prototype.quote = function(sym) {
    if (!sym) {
        sym = '"';
    }
    return sym + this + sym;
};

Related

  1. dequote()
    String.prototype.dequote = function() {
      return this.replace(/^"|"$/g, '');
    
  2. quote(()
    String.prototype.quote = (function(){
        return '"' + this + '"';
    })
    
  3. quote()
    String.prototype.quote = function () {
        var c, i, l = this.length, o = '"';
        for (i = 0; i < l; i += 1) {
            c = this.charAt(i);
            if (c >= ' ') {
                if (c === '\\' || c === '"') {
                    o += '\\';
                o += c;
    ...