이미 isArray 가 존재함...;;
뭔가 너무 어렵게 풀어낸듯?
Array.prototype.isArray =()=> toString.call(this) == '[object Array]';
Array.prototype.sameStructureAs = function (other) {
return this.length == other.length?
this.map((a,i)=> {
var b = other[i];
if (isArray(a) && isArray(b)) {
if (a.length != b.length) return false;
else return a.sameStructureAs(b);
} else if (isArray(a) && !isArray(b)) return false;
else return true;
}).every(f=>f==true) : false;
};
역시 심플 이즈 배러
Array.prototype.sameStructureAs = function (other) {
return (this.length === other.length) ? this.every(function(el, i){
return Array.isArray(el) ? el.sameStructureAs(other[i]) : true;
}) : false;
};