묻고 답해요
129만명의 커뮤니티!! 함께 토론해봐요.
인프런 TOP Writers
-
해결됨만들면서 배우는 리액트 : 기초
구조 분해 문법(Destructuring)질문
1:21 에서 말씀해주신 구조분해문법(Destructuring)에 질문이 있습니다. 알려주신 주소에 나와있는 자료를 보면 다음과 같습니다. 이 코드에서 var { language, position, area, hobby, age} = josh; 와 같은 코드가 있어야 디스트럭처링 문법이 실행하는 것을 개발자 도구를 통해 확인했습니다. 그런데 const MainCard의 변수로 넣은 {img}는 저희가 var {img} = props와 같이 선언한 적이 없는데 잘 작동하고 있습니다. 이것이 가능한 이유가 무엇인지 알고 싶습니다.
-
해결됨모던 자바스크립트(javascript) 개발을 위한 ES6 강좌
로또 번호 생성기 소스코드
function makeLottoNumber() { const lottoList = new Set(); while (lottoList.size < (CONFIG.bonus ? 7 : 6)) { const random = Math.floor(Math.random() * CONFIG.maxNumber + 1); lottoList.add(random); } console.log(CONFIG.title); const result = [...lottoList]; if (CONFIG.bonus) { const bonusNum = result.pop(); return { number: result, bonus: bonusNum }; } else { return { number: result }; } } const CONFIG = { title: "Happy Lotto Time!", maxNumber: 45, bonus: true, }; console.log(makeLottoNumber());참고용으로 올립니다.