[요약] live collection과 static collection

DL·2022년 7월 12일
0

요약

1. DOM에는 웹에 동적으로 변경사항을 반영해주는 live collection과 정적으로 반영해주는 static collection이 있다.

2. HTMLCollection은 live collection이고 querySelectorAll()이 반환하는 NodeList를 제외한 대개의 NodeList 또한 live collection이다.

3. 메소드를 구분하면 아래와 같다.

//HTMLCollection을 반환하는 메소드
document.getElementsByClassName()
document.getElementsByTagName()

//NodeList를 반환하는 메소드
document.getElementsByName()
document.querySelectorAll() // 정적인 NodeList를 반환한다.

참고

MDN - NodeList
MDN - HTMLCollection
CodePlayground님의 블로그
큐트리님의 블로그
스택오버플로우

profile
어제보다 오늘, 오늘보다 내일 더 성장하는 프론트엔드 개발자

0개의 댓글