1-02.콘솔(Console)

2023. 3. 28. 10:48Javascript/자바스크립트 제대로 배워볼래?

다음과 같이 script안에 console.log를 이용하여 콘솔에 출력하면된다.

 

1-02.콘솔(Console).html

<!DOCTYPE html>
<html>
<head>
    <title>Document</title>
</head>
<body>
    <script>
        console.log("콘솔창에 출력합니다.");
        document.write("화면에 메시지를 출력합니다.");
    </script>
</body>
</html>

 

이는 다음과 같이 에러가 어떤부분에서 났는지를 알게 해준다는 이점에 사용한다.

document.wrㅐite("화면에 메시지를 출력합니다.");