String that contains all ascii characters

前端 未结 7 1315
灰色年华
灰色年华 2021-02-03 23:01

I want to create a string in JavaScript that contains all ascii characters. How can I do this?

7条回答
  •  旧巷少年郎
    2021-02-03 23:44

    Without doing several appends:

    var s = Array.apply(null, Array(127-32))
      .map(function(x,i) {
        return String.fromCharCode(i+32);
      }).join("");
      document.write(s);

提交回复
热议问题