Lodash - unescape 方法



語法

_.unescape([string=''])

(_.escape) 的反向操作;此方法會將字串中的 HTML 實體 &、<、>、“和 ' 轉換為其對應的字元。

引數

  • [string=''] (string) − 要取消轉義的字串。

輸出

  • (string) − 返回取消轉義後的字串。

示例

var _ = require('lodash');
var result = _.unescape('Joe, Julie, &amp; Robert');

console.log(result);

將上述程式儲存在 tester.js 中。執行以下命令以執行此程式。

命令

\>node tester.js

輸出

Joe, Julie, & Robert
lodash_string.htm
廣告
© . All rights reserved.