SOURCE

console 命令行工具 X clear

                    
>
console
// 方法1:fill
const getArray1 = (m, n) => {
    return new Array(m).fill(new Array(n).fill(0))
}

// 方法2:fill
const getArray2 = (m, n) => {
    return Array.from({ length: m }, (m) => Array.from({ length: n }, (n) => 0))
}

console.log(getArray1(5, 3))
console.log(getArray2(5, 3))

function createBlock(m, n) {
    const vnode = document.createDocumentFragment()
    for (let i = 0; i < m; i++) {
        const line = document.createElement('div')
        for (let j = 0; j < n; j++) {
            const block = document.createElement('span')
            block.innerText = i * n + j + 1
            line.appendChild(block)
        }
        vnode.appendChild(line)
    }
    document.body.appendChild(vnode)
}

createBlock(6, 6)
<body>

</body>
body {
    display: flex;
    flex-direction: column;
    align-items: center;
}

div {
    display: flex;
}

span {
    border: 1px solid #000;
    width: 30px;
    height: 30px;
    display: inline-block;
    text-align: center;
    line-height: 30px;
}

span:hover {
    background-color: blue;
}