강의

멘토링

커뮤니티

Inflearn Community Q&A

shrkdvy12341420's profile image
shrkdvy12341420

asked

Introduction to Javascript Algorithm Problem Solving (Coding Test Preparation)

12. Combination Number (Memoization)

Array.from vs Array.fill 질문

Written on

·

519

0

두 방식으로 각각 선언했을때 답이 다르게나옵니다... 뭐가 잘못된걸까요..?

  1. Array.from으로 선언했을때1.png1-1.png2. Array.fill로 선언했을때

    2.png2-1.png

javascript코딩-테스트

Answer 2

1

codingcamp님의 프로필 이미지
codingcamp
Instructor

안녕하세요^^

Array.fill이 방법이 얕은 복사가 되서 그러는 것 같습니다. 아래와 같이 해보세요.

let dy = new Array(35).fill(0).map(() => new Array(35).fill(0));

0

shrkdvy12341420님의 프로필 이미지
shrkdvy12341420
Questioner

그렇군요..! 감사합니다!

shrkdvy12341420's profile image
shrkdvy12341420

asked

Ask a question