const title = document.getElementById("title");
function handleResize(){
console.log("resize")
}
window.addEventListener("resize", handleResize);
이 코드에서
handleResize는
handleResize()일 때 -> 바로 호출
handleResize일 때 -> 필요할 때 호출 즉 화면 크기를 변경했을 때! 콘솔에 적어버린다.
const title = document.getElementById("title");
function handleResize(event){
console.log(event)
}
window.addEventListener("resize", handleResize);
이 로그는 handleResize()로 썼을 때랑 같은 동작을 하게된다.
resize는 form을 만들거나 link를 달아주는 작업을 수행할 때 유용하다.