📜  javascript 字符串转换为长度的子字符串 - Javascript 代码示例

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

代码示例1
function chunkSubstr(str, size) {
  const numChunks = Math.ceil(str.length / size)
  const chunks = new Array(numChunks)

  for (let i = 0, o = 0; i < numChunks; ++i, o += size) {
    chunks[i] = str.substr(o, size)
  }

  return chunks
}