목록자바스크립트 (4)
인사이트
1. html에서 script속성을 이용해서 이벤트를 처리하는 방법 - 코드 해석 html : 나는 버튼을 하나 만들건데, 버튼의 onmouseover(버튼 위에 마우스를 댔을 때 일어나는 이벤트)와 onmouseout(버튼 위에 마우스를 치웠을 때 일어나는 이벤트)라는 이벤트를 2개 줄거야. 그 때 chColor라는 함수가 실행되게 하고 그 함수의 전달인자로 this와 'over'을 줄거야 javascript : 나는 chColor라는 함수고 나를 실행할때는 반드시 obj와 state라는 매개변수를 받아줘야해. 받아왔으면 이런 조건에 맞게 작동이 되는데. 어떤 조건이냐면, 만약 chColor호출하면서 state자리에 "over"라는 값을 썼다면 색상을 빨간색으로 바꿔주고, 아니라면 검정색으로 바꿔줘. ..
1. Browser Object Model - 웹 브라우저와 관련한 객체(개발자가 이미 만들어진(제공해준) 기능을 가져다가 쓸 수 있도록 한 것)의 모음 2. window객체가 BOM 중 최상위 - 그래서 생략이 가능하다 ex) window.document.write(); // 자바스크립트에서 브라우저에 보여질 수 있게 해주는 코드 위 대신 document.write();만 해도 잘 동작한다. 왜 잘 동작할까? - document위에는 window밖에 없기 때문에(BOM 그림 확인하면 이해감) 굳이 써주지 않아도 document앞에는window겠거니 라고 판단하기 때문 3. setInterval함수 - 1초마다 특정 동작을 수행하게 할 수 있는 함수 - 짝꿍으로는 clearInterval()이 있다 - ..
1. document.write(); : 화면에 보여지게 하는 명령어이다 : 해당 코드를 이용해서 html의 태그도 그대로 표현할 수 있다 2. 증감연산자 1) 후위연산자 or 후치연산자 : i++(= i+1) 이런 식으로 쓰인다. : 나는 여유가 좀 있으니까 너네 계산 다 끝난 다음에 나 1 증가해줘 i는 1 j는 i++ + 1 후위연산자의 i는 여유가 좀 있으므로 i + 1을 먼저 계산해서 j에 넣고, 그 다음 ++를 계산해준다. 그러면 j는 2가 되겠고, i는 남은 ++계산을 해줘야하니까 2가 된다 2) 전위연산자 or 전치 연산자 : ++i(= i+1) 이런 식으로 쓰인다. : 급해 죽겠으니까 일단 나부터 1증가시키고 나머지 계산해 i는 1 j는 i++ + 1 전위연산자의 i는 성격이 급하기 때문..