编辑代码

/*建议使用浏览器控制台编译
摘抄自:https://www.it1352.com/1006098.html
*/

let a = "<p>10.1&#8243; 1920 x 1200 IPS Display; &#8243;  RAM &amp; e";
function htmlCode2Char(str) {
    let reg = /&#.*?;/g;
    return str.replace(reg, m => {
        let _reg = /&#(.+?);/g;
        let code = _reg.exec(m);
        return code && String.fromCharCode(code[1]);
    });
};
String.prototype.decodeHTML = function () {
    var map = { "gt": ">" /* , … */ };
    return this.replace(/&(#(?:x[0-9a-f]+|\d+)|[a-z]+);?/gi, function ($0, $1) {
        if ($1[0] === "#") {
            return String.fromCharCode($1[1].toLowerCase() === "x" ? parseInt($1.substr(2), 16) : parseInt($1.substr(1), 10));
        } else {
            return map.hasOwnProperty($1) ? map[$1] : $0;
        }
    });
};

let bb = htmlCode2Char(a)
let cc = a.decodeHTML()

console.log(bb)
console.log(cc)