久而酒知

文章 评论 浏览 30

久而酒知 2022-05-04 13:56:53

function push (arr, item) {
arr[arr.length] = item;
}

第 46 题:输出以下代码执行的结果并解释为什么?

久而酒知 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
    }
}

第 114 题:找出字符串中连续出现最多的字符和个数

久而酒知 2022-05-04 13:48:40

@hellobabyting

var fs = require('fs')

// callback usage
fs.readdir('./', function (err, files) {
  ...
})

// promisify
let promisifyReadDir = promisify(fs.readdir)
promisifyReadDir('./').then(files => {
  console.log(files)
})

ES6 系列之我们来聊聊 Promise

久而酒知 2022-05-04 07:00:39

@alanchanzm 1. class 声明会提升 . 是不是写错了?
原文: Class declarations, unlike function declarations, are not hoisted.

第 7 题:ES5/ES6 的继承除了写法以外还有什么区别?

更多

推荐作者

櫻之舞

文章 0 评论 0

弥枳

文章 0 评论 0

m2429

文章 0 评论 0

野却迷人

文章 0 评论 0

我怀念的。

文章 0 评论 0

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文