LoginSignup
1
1

More than 5 years have passed since last update.

underscoreコードリーディング(unescape)

Posted at

underscoreに詳しくないので、勉強半分でソースコードを読む。

利用するバージョン

underscore.js(v1.8.3)

unescapeとは

underscorejs.orgのunescape

こんな説明。



underscore.unescape

コード的にはこのあたり。


_.unescape = createEscaper(unescapeMap);

.escapeと同じだが、渡す引数がunescapeMap.
unescapeMapはescapeMapを
.invertしたもの.
そのため、&を&へと変換する。

unescapeMap

   // List of HTML entities for escaping.
  var escapeMap = {
    '&': '&',
    '<': '&lt;',
    '>': '&gt;',
    '"': '&quot;',
    "'": '&#x27;',
    '`': '&#x60;'
  };
  var unescapeMap = _.invert(escapeMap);

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1