function EnglishClass(name, age, id){
this.name = name;
this.age = age;
this.id = id;
this.sayHello = function(){
console.log(`Hi I am ${this.name}`)
}
}
const jack = new EnglishClass('잭', 20, 1);
const add = function addNums (num1,num2){
return num1 + num2 ;
}
const minus = function (num1,num2){
return num1 - num2 ;
} // function의 이름은 생략 가능
typeof add //function
add(1,2) //3
console.log('두 수의 합계는 ',add(1,2),' 입니다');
const calculator = [add,minus];
calculator.add(2,3) //5
◾ transition
이 처음 생성될 때
◾ transition-delay
가 시작되기 전에 발생한다.
◾ transition
이 실제로 실행될 때
◾ transition-delay
가 종료된 후 발생
◾ transition
이 완료되면 발생
◾ transitionrun
→ transitionstart
→ transitionend
◾ transition
이 취소되는 상황에서 발생
◾ 예외: 원상태로 돌아가는 부분에도 스타일이 변경되면 cancel이 아니다
const input = document.querySelector("input");
input.addEventListener("focus", () => {
input.classList.add("expand");
input.addEventListener("transitionend", () => {
input.classList.add("highlight");
});
});
input.addEventListener("focusout", () => {
input.classList.remove("expand");
input.addEventListener("transitionend", () => {
input.classList.remove("highlight");
});
});
◾ 예를 들어 한 컴포넌트에 두개의 효과를 주고싶을때 활용할 수 있음
◾ 해당 예시의 경우 expand의 클래스가 붙으며 transition
이 발생할 때, 발생 후 highlight의 클래스가 추가되는 이벤트이다. (focus 이벤트기준)
◾ animation
이 처음 생성되고 시작될 때
◾ animation-delay
가 있다면 delay시간을 기다린 후 animationstart
가 발생한다.
◾ animation
이 반복될 때 발생된다.
◾ animation
이 끝나고 다음 animation
이 시작하기 전에 발생
◾ animation
이 끝날때 발생
◾ animationstart
→ animationiteration
→ animationend
◾ 2번째 에니메이션 시작 전에 animationiteration
이 발생
◾ animation
이 중단하게 되면 발생하는 이벤트