JSFiddle - React, Tailwind, and code Playground
JavaScript
var a = [
[1, 2],
[3, {x: 5}]
],
b = a.slice(),
c = cloneDeep(a);
a[1][1].x = 9;
function cloneDeep(mas) {
var masClone = Array.isArray(mas) ? new Array(mas.length) : {};
Object.keys(mas).forEach(function (key) {
if (Array.isArray(mas[key]) || Object.prototype.toString.call(mas[key]) === "[object Object]")
masClone[key] = cloneDeep(mas[key]);
else
masClone[key] = mas[key];
});
return masClone;
}
console.log(a[1][1].x, b[1][1].x, c[1][1].x);