grid.slice(x,x+3)
If the second value in slice is larger than the length it slices to the end. It could be a 2x10 or 1x10 but lets pretend it is 3.
.map(g=>g.slice(y,y+3))
.flat()
.includes(num)
If the second value in slice is larger than the length it slices to the end. It could be a 2x10 or 1x10 but lets pretend it is 3.
Does the same with each row making it into a 3x3 (or 2x3 or 1x1 etc) Turns the 3x3 into a flat array of up to 9 values. tests if the flat sliced array include num.