packages/fbjs/src/unicode/UnicodeUtilsExtra.js
function jsEscape(s) {
  var result = '"';
  for (var i = 0; i < s.length; i++) {
    let cp = s.charCodeAt(i);
    let special = specialEscape[cp];
    if (special !== undefined) {
      result += special;
    } else if (cp >= 0x20 && cp <= 0x7e) {
      result += String.fromCodePoint(cp);
    } else {
      result += '\\u' + zeroPaddedHex(cp, 4);
    }
  }
  result += '"';
  return result;
}
function jsEscape(s) {
  var result = '"';
  for (var i = 0; i < s.length; i++) {
    let cp = s.charCodeAt(i);
    let special = specialEscape[cp];
    if (special !== undefined) {
      result += special;
    } else if (cp >= 0x20 && cp <= 0x7e) {
      result += String.fromCodePoint(cp);
    } else {
      result += '\\u' + zeroPaddedHex(cp, 4);
    }
  }
  result += '"';
  return result;
}
function jsEscape ( s ) { var result = '"' ; for ( var i = 0 ; i < s . length ; i ++ ) { let cp = s . charCodeAt ( i ) ; let special = specialEscape [ cp ] ; if ( special !== undefined ) { result += special ; } else if ( cp >= 0x20 && cp <= 0x7e ) { result += String . fromCodePoint ( cp ) ; } else { result += '\\u' + zeroPaddedHex ( cp , 4 ) ; } } result += '"' ; return result ; }
Returns a double-quoted Java or JavaScript string with all
non-printable and non-US-ASCII sequences escaped.

@param {string} str Valid Unicode string
@return {string}    Double-quoted string with Unicode sequences escaped
Returns a double - quoted Java or JavaScript string with all non - printable and non - US - ASCII sequences escaped .