자바스크립트 출력 (결과물 출력)
- window.alert()
- innerHTML(by dom)
- document.write
- console.log
document.write 예시
<h1 id="test">테스트</h1>
<h1>document.write??</h1>
<h1>document.write??</h1>
<h1>document.write??</h1>
<button onclick="document.write('날 누른걸 후회할걸');">절대 누르지 마세요</button>
<script>
테스트
document.write??
document.write??
document.write??
절대 누르지 마세요
- 웹 페이지 로딩 시 웹 페이지에 가장 먼저 데이터를 출력하는 방법
- 주의 사항
--> 모든 내용이 로딩이 된 후 document.write가 실행되면 먼저 로딩된 요소를 전부 지우고 document.write의 내용만 출력된다.
console.log
console.log(document.getElementById("test"));

alert vs console.log(코드검사(디버깅))
- alert의 경우는 js 코드의 진행을 막을 수 있다.
- alert은 이벤트의 진행 순서를 파악하고 싶을 때 사용한다.
- console은 전반적인 흐름에 영향을 주지 않으면서 데이터의 흐름을 보고 싶을 때 사용한다.