목록JavaScript (33)
솔미는 성장중
🎃 .addEventListener() 대상에 이벤트 청취(listen)을 등록. 대상에 지정한 이벤트가 발생했을 때 지정한 함수(Handler) 호출 ex) click, dbclick(더블클릭시), wheel, keydown, mousedown(버튼 누를때), mouseup(버튼 뗄때), mouseenter(포인터가 요소 위로 올라갈 때), mouseleave(포인터가 요소 밖으로 나올 때), mousemove(포인터가 움직일 때), contextmenu(우클릭했을 때) 등등.. click 예시) childEl.addEventListener('click',() => { childEl.classList.toggle('active') //actvie클래스 있으면 없애고, 없으면 만들고. }) wheel 예..
보호되어 있는 글입니다.
원시 데이터의 "데이터 불변성" 원시 데이터 : String, Number, Boolean, null, undefined 원시 데이터에서는 단순하게 모양이 다르면 false가 나온다고 생각해도 틀리진 않는다. 하지만 정확히는 '메모리 주소'가 같고 다름에 따라 true/false가 바뀐다. let a = 1 let b = 4 console.log(a,b,a===b) //1 4 false -> 메모리 주소가 달라서 false b=a console.log(a,b,a===b) //1 1 true -> b가 a가 가리키는 메모리주소를 가리키게 됨 a=7 console.log(a,b,a===b) //7 1 false -> 메모리 주소가 달라서 false 새로운 원시 데이터를 사용했을 때 그 원시 주소가 기존 메모..
Node 와 Element 노드 : HTML 요소, 텍스트, 주석 등 모든 것을 의미 //NodeList 요소 : HTML 요소 의미 //HTMLcollection 1 텍스트1 2 텍스트2 const parent = document.querySelector('.parent') console.log(parent.childNodes) //부모 요소의 모든 자식 "노드"확인 //NodeList(7) [text, comment, text, div.child, text, div.child, text] //0: text (줄바꿈 문자) //1: comment (주석) //2: text (줄바꿈 문자) //3: div.child //4: text (줄바꿈 문자 & 텍스트1) //5: div.child //6: tex..
fetch (주소, 옵션) 네트워크를 통해 리소스의 요청(request)과 응답(response)을 처리한다 promise 인스턴스를 반환 console.log(fetch('https://www.omdbapi.com/?apikey=********&s=avengers')) //Promise 📍 fetch를 통해 promise 인스턴스를 반환하니 뒤에 then 메소드를 써줄 수 있다. fetch('https://www.omdbapi.com/?apikey=********&s=avengers')) .then(res => console.log(res)) //Response 📍 json 메소드를 호출해야 데이터를 꺼낼 수 있다. fetch('https://www.omdbapi.com/?apikey=********&..