I\'m implementing a John Conway Game of Life, but I\'m having a weird problem. Here is a short version if the code giving me trouble:
let lifeMap = [
[true
You may clone an ND (deeply nested) array as follows;
Array.prototype.clone = function(){
return this.map(e => Array.isArray(e) ? e.clone() : e);
};
or if you don't want to modify Array.prototype
you may simply refactor the above code like;
function cloneArray(a){
return a.map(e => Array.isArray(e) ? cloneArray(e) : e);
};