📜  javascript 设置字符串的最大长度 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:02:06.590000             🧑  作者: Mango

代码示例2
(function() {
    strings = ["z"];
    try {
        while(true) {
            strings.push(strings[strings.length - 1] + strings[strings.length - 1]);
        }
    } catch(err) {
        var k = strings.length - 2;
        while(k >= 0) {
            try {
                strings.push(strings[strings.length - 1] + strings[k]);
                k--;
            } catch(err) {}
        }
        console.log("The maximum string length is " + strings[strings.length - 1].length);
    }
})();