
브라우저는 HTML을 열고, HTML은 CSS와 자바스크립트를 가져온다.
HTML이 접착제다
variable을 만들기 위한 방법
1. const 사용함. -> 값이 바뀔 수 없음, 기본적으로 사용함.
constant = 상수 = 바뀌지 않는 값
2. let 사용함. -> 값을 바꾸는 게 필요할 때 variable을 업데이트 하고 싶을 때 사용함.
기본적으로는 const를 사용하고, 필요할 때만 let 사용하되, var은 쓰지 말 것.
항상 const, 가끔 let, 사용X var.
const a = 10;
const b = 3;
let myName = "jinah";
console.log(a + b); // 13
console.log(a * b); // 30
console.log(a / b); // 3.3333333333333335
console.log("Hello " + myName); // Hello jinah
myName = "eunwoo";
console.log("your new name is " + myName); // your new name is eunwoo
true, false, null, undefined
자바스크립트의 데이터 타입 중에는 '존재하지 않음' 또는 '정의되지 않음' 또는 'null=아무것도 없음'이 있다.
켜져있음
꺼져있음
비어있음
something이라는 variable을 만들고 있지만, 값을 주고 있지 않은 것.
variable은 존재하는데 정의되지 않은 것.
컴퓨터 메모리 안에는 존재함. 공간은 있지만 값이 들어가지 않은 것.
array 안에서 항목을 받아올 수 있다.
array에 하나 더 추가할 수 있다.
[]를 사용해야 한다.const daysOfWeek = ["mon", "tue", "wed", "thu", "fri", "sat"];
// Get Item from Array
console.log(daysOfWeek);
// Add one more day to the array
daysOfWeek.push("sun");
console.log(daysOfWeek);
property를 가진 데이터를 저장하도록 해준다.
const player = {
name: "jinah",
points: 50,
handsome: true,
fat: false,
};
console.log(player); // {name: 'jinah', points: 50, handsome: true, fat: false}
player.points = player.points + 15;
console.log(player.points); // 65