久而酒知 2022-05-04 13:55:09
function getRepetCount(str) { let maxChars = ''; let maxCount = 0; let length = str.length; let count = 1; for (let index = 1; index < length; index++) { const cur = str[index]; const pre = str[index - 1]; if (cur === pre) { count++; } else { if (count > maxCount) { maxCount = count; maxChars = pre; } count = 1; } } return { [maxChars]: maxCount } }
久而酒知 2022-05-04 13:48:40
var fs = require('fs') // callback usage fs.readdir('./', function (err, files) { ... }) // promisify let promisifyReadDir = promisify(fs.readdir) promisifyReadDir('./').then(files => { console.log(files) })
久而酒知 2022-05-04 07:00:39
@alanchanzm 1. class
声明会提升 . 是不是写错了?
原文: Class declarations, unlike function declarations, are not hoisted.
- 共 1 页
- 1
function push (arr, item) {
arr[arr.length] = item;
}
第 46 题:输出以下代码执行的结果并解释为什么?