1. 程式人生 > >Node.js快速生成26個字母

Node.js快速生成26個字母

const buf1 = Buffer.allocUnsafe(26); for (let i = 0; i < 26; i++) { // 97 是 'a' 的十進位制 ASCII 值。 buf1[i] = i + 97; } console.log(buf1.toString('ascii')); // 輸出: abcdefghijklmnopqrstuvwxyz console.log(buf1.toString('ascii', 0, 5)); // 輸出: abcde