을 넣어주면 된다."> 을 넣어주면 된다."> 을 넣어주면 된다.">
index.html을 브라우저로 끌어서 볼 수도 있지만, live server이라는 확장 프로그램의 도움을 받아 템플릿을 브라우저에서 바로 볼 수 있다. script.js파일을 변경해서 화면에 나타낼 때, <body> 에 <script> 태그를 활용하여 <script src="script.js"></script>을 넣어주면 된다.
객체안에는 여러가지 메소드들이 있다. 가장 자주 사용하는 것은 log 메소드 이다.
console.log('안녕하세요!');
console.log(1234567);
console.log({a:'a'});
console.table({a: 'a'});
console.error('Error');
빨간바탕 에러발생
console.warn('Warning');
노란바탕 경고발생
console.time('hello');
console.log(1);
console.log(2);
console.log(3);
console.timeEnd('End');
=> 걸리는 시간(ms)을 계산
console.clear();
변수 선언 방식은 세가지가 있으며, var은 중복선언과 재할당이 가능하고, let은 중복선언이 불가하고, 재할당은 가능하다. const는 중복선언과 재할당 모두 불가능하다.
var greeting :'hello';
console.log(greeting); // hello
출력을 한다. greeting 변수에 hello라는 값을 할당
var greeting = 'hi';
console.log(greeting); //hi
greeting = 'how are you?';
console.log(greeting);
//how are you?
재할당만 다시한다. 에러 x
선언, 할당 여러번 해도 에러가 없다.
let greeting :'hello';
console.log(greeting); // hello
출력을 한다. greeting 변수에 hello라는 값을 할당
let greeting = 'hi';
console.log(greeting); //에러
//한번 선언하면 다시 할당이 안된다 **에러 발생!**
greeting = 'how are you?';
console.log(greeting);
재할당은 가능하다.
const greeting :'hello';
console.log(greeting); // hello
출력을 한다. greeting 변수에 hello라는 값을 할당
const greeting = 'hi';
console.log(greeting); //에러
//한번 선언하면 다시 할당이 안된다 **에러 발생!**
//**'already been declared' 에러**
greeting = 'how are you?';
console.log(greeting);
**//에러 발생!
//uncaught typeerror: assignment to constant variable**
재할당도 에러가 발생한다.
배열에 1,2,3이 존재하고, push라는 메소드로 4를 사용하는데,
object 프로퍼티에 c라는 값을 가져와도, c가 잘 들어가 있는 것을 볼 수 있다.

못하게 하려면, 타입스크립트를 이용한다.