2
* @param {number[][]} board3
* @return {void} Do not return anything, modify board in-place instead.5
var gameOfLife = function (board) {6
const m = board.length,8
let copy = JSON.parse(JSON.stringify(board));10
const getNeighbor = (row, col) => {11
let radius = [-1, 0, 1],13
for (let i = 0; i < 3; i++) {14
for (let j = 0; j < 3; j++) {16
!(radius[i] == 0 && radius[j] == 0) &&17
copy[row + radius[i]] &&18
copy[row + radius[i]][col + radius[j]]20
let neighbor = copy[row + radius[i]][col + radius[j]];30
for (let i = 0; i < m; i++) {31
for (let j = 0; j < n; j++) {32
const count = getNeighbor(i, j);33
if (copy[i][j] == 1) {34
if (count < 2 || count > 3) {