Console.log & Slash (/)

수경, Sugyeong·2021년 8월 22일
0

JavaScript

목록 보기
1/18
post-thumbnail

console.log 와 주석을 처리하는 방법에 대해 알아본다.




💡 console.log란?

Javascript 의 대표적인 디버깅 방법이다.
쉽게 말하자면 Javascript 가 괄호 안의 값을 화면에 출력 할 수 있도록 도와주는 기능이다.

💡 console.log 사용 방법

console.log(출력할 대상);

<예시>

console.log(100);

콘솔창 화면에 100이 출력 되는 것을 확인할 수 있다.

💡 console 창 사용하기

  1. 브라우저 상에서 우클릭 후 Inspect 클릭 / F12 / Ctrl+Shift+I
  2. Replit 이나 Jsbin 등의 서비스 활용

💡 주석 처리하기

주석은 코드를 설명하는 코멘트로 실제로 동작하는 코드가 아니다.
slash (/) 를 사용하여 처리해준다.

<예시 - 한 줄을 주석 처리하는 경우>

console.log("yellow"); // 색상

<예시 - 여러 줄을 주석 처리하는 경우>

console.log("lyrics");

/*
Always been a dreamer will you dream with me
If I should lose my way then would you follow me
Always been a dreamer will you dream with me
And if I stay like this then will you stay with me
*/

0개의 댓글