JSFiddle - React, Tailwind, and code Playground

JavaScript

var cols = 9;
var rows = 9;
var matrix_empty = [];

function getRandomMatrix(matrix) {
    matrix[0][1] = 39;
    matrix[1][1] = 9;
    matrix[2][2] = 9;
    return matrix;
}

for (var x = 0; x < cols; x++) {
    matrix_empty[x] = [];
    for (var y = 0; y < rows; y++) {
        matrix_empty[x][y] = -1;
    }
}
console.clear();
console.log(matrix_empty); //here give me wrong result not -1 in whole position

setTimeout(function() { 
    matrix_test = getRandomMatrix(matrix_empty);
    console.log(matrix_empty);

}, 10000);