본문 바로가기

JavaScriptVeryBeiginning

DOM(doc obj model) 여기 엘리먼트가 하나 있습니다 자식도 하나 있습니다 자식도 여럿 있습니다 JavaScript를 이용해서 엘리먼트의 속성값을 얻어내거나, 변경하는 법. 트리구조의 html을 JS 객체형태로 바꾸어보면! 위의 html 문서의 구조&관계를 객체(obj)로 표현한 모델. 마찬가지로 트리구조 document라는 "전역변수"로 접근이 가능해진다!!!!!!!!! (recursion 과제 때 꼭 알아야했던 개념!) DOM은 절대 JS는 아니지만 그저 JS를 이용해서 dom 구조에 접근 할 뿐?? i.e. "document.~"이런 방식으로 접근했었다. future-me will elaborate on this. { tagName: 'DIV', id: 'practice', classList: ['highlight', '.. 더보기
HTML opening default 더보기
What's the difference between return and console.log? 함수 바깥으로 결과 가져오기. console.log는 단순 출력(print)만 하기 때문에 return 이라는 키워드를 사용해 출력 결과를 가져올 수 있어야한다. 함수 안에 console.log만 있다면 그 함수는 결과값이 없는 함수가 된다. const checkThatTwoPlusTwoEqualsFourAMillionTimes = () => { for(let i = 1; i 더보기
Using let keyword in relation to reassignment and scope pollution let num = 50; const logNum = () => { num = 100; // Take note of this line of code console.log(num); }; logNum(); // Prints 100 console.log(num); // Prints 100 In here: We have a variable num. Inside the function body of logNum(), we want to declare a new variable but forgot to use the let keyword. ??Why does it matter? What difference does it make when we use let keyword? When we call logNum(), .. 더보기
var과 let의 차이? var 일때만 넘어가는 이유는 무엇? **18jun20 코플릿 참고!!** https://www.geeksforgeeks.org/difference-between-var-and-let-in-javascript/#:~:text=var%20and%20let%20are%20both,program%20as%20compared%20to%20let. Difference between var and let in JavaScript - GeeksforGeeks A Computer Science portal for geeks. It contains well written, well thought and well explained computer science and programming articles, quizzes .. 더보기
function(name) name must be input as a string function sayThanks(name){) { console.log('Thank you for your purchase '+name+'! We appreciate your business.'); });}}}}}} sayThanks('Cole'); 여기서 이름이 문자열로 들어가야하는 이유는 결과값이 문자열로 나와야하기 때문? 그렇다면 name을 입력할 때 문자열로 입력해야한다는 조건은 없어도 괜찮은가? console.log('Thank you for your purchase ${name}! We appreciate your business.');라고 하면 문자열로 입력안해도 무관한가? 더보기