asked
Introduction to Javascript Algorithm Problem Solving (Coding Test Preparation)
2. Path search (DFS-adjacency matrix: when the number of nodes is small)
Written on
·
189
0
let c = Array.from({length : 5}, () => []); c[0] === c[1]; // false let d = Array(5).fill([]); d[0] === d[1]; // true
이렇게 나오더라구요
두 방식의 차이가 뭐길래 저렇게 나오는건가요??
Answer 1
안녕하세요^^
아래 질문과 동일한 원리입니다.
2차원을 만들때 얕은 복사냐 깊은 복사냐의 문제입니다.