JavaScript (17) 썸네일형 리스트형 이벤트 리스너 이벤트 리스너 이벤트 버튼 이벤트 삭제 버튼 이벤트 기본 이벤트 타입 문자열을 클릭하세요 이벤트 이벤트(Event) - 웹 브라우저가 알려주는 HTML 요소에 대한 사건을 발생 - 웹 페이지에 사용된 자바스크립트는 발생한 이벤트에 반응하여 특정 동작을 수행할 수 있음 - 자바스크립트는 비동기식(동시발생) 이벤트 중심의 프로그래밍 모델 ------- ------- ----- 이벤트 타겟, 이벤트타입, 이벤트 리스너 이벤트타입(Event Type) - 발생한 이벤트의 종류를 나타내는 문자열로 이벤트명이라고도 함 - 키보드, 마우스, HTML DOM, window 객체등을 처리하는 이벤트 제공 이벤트타겟(Event Target) - 이벤트가 일어날 객체를 의미 //버튼클릭했을때 이벤트리스너발생? 이벤트리스너(Event Listener) - 이벤트가 발생했을 때 그 처리를 담당하는 함수 - 이벤트 핸들러라.. Wrapper 래퍼클래스-기본타입(long, byte char boolean...) 데이터 하나만 담을 수 있다. 기능들을 포함해서 만든 기본타입과 1대1로 래핑되어있다 래퍼 객체(Wrapper Object) const num =10; -->객체x console.log(num); //10 const num = 10; console.log(typeof(num));//num의 타입은 number console.log(num);// 10 console.log(num.toString());//문자열타입으로 10 console.log(num);//10 //지수 표기법(toExponential()) const num = 102; console.log(num2.toExponential());//1.02e+2//102가 왜 1.02.. 생성자?? class Employee{ constructor(name, dep, time, payRate){ this.name=name; this.dep=dep; this.time=time; this.payRate=payRate; } calculatePay(){ return this.time * this.payRate; } } class FullTimeEmployee extends Employee{ static payRate = 20000; constructor(name, dep, time){ super(name, dep, time, FullTimeEmployee.payRate); } } class PartTimeEmployee extends Employee{ static payRate = 10000; constr.. counter class Counter{ #value; //프라이빗 constructor(value){ if(isNaN(value)||value { this.#value++; } } class 클래스명{ #변수명; //private로 class 외부로 나가면 쓸 수 없다!? } const counter = new Counter(0); //0이 value로 이동 counter.increment();// 1번 쓰면 1 counter.increment();//2번 썻으니 2 console.log(counter.value);출력(값);.. 상속! class Animal { constructor(color){ this.color = color; } eat(){ console.log('먹는다!'); } sleep(){ console.log('잔다!'); } } class Dog extends Animal{ play(){ console.log('놉니다!'); } } class Cat extends Animal{ constructor(color, name){ super(color); this.name = name; } // 오버라이딩 eat(){ console.log('맛있게 먹는다!'); } } const Rucy = new Dog('white'); console.log(Rucy); //Dog { color: 'white' } Rucy.eat(); /.. class //객체를 만드는 템플릿 1. 생성자 함수 2. 클래스 --> // static: 정적 프로퍼티 class Fruit{ static count_fruits = 0; constructor(name, emoji){//constructor? 자바의 생성자 this.name = name;//자바의 this this.emoji = emoji; } display = () => { console.log(`${this.name}: ${this.emoji}`); } static makebanana() { return new Fruit(`banana`, `🍌`); //클래스 레벨 메소드에서 this를 참조할 수 없음 } } //stw는 Fruit 클래스의 인스턴스 const stw = new Fruit('stw','🍓').. 이전 1 2 3 다음