1)console.log();
콘솔에 log 또는 print
1. variable
const a=5; >변하지 않음
>기본 타입은 string
1-1)let b="2"; >변경,update할 수 있음
생성할 때
b=4
업데이트 할 때
1-2)const myName
띄어쓰기해야할 때는 대문자 쓰기
//항상 const, 가끔 let, 절대x var
2.
null :"비어 있음" 이라는 값이 있다
undefined: 아무것도 없음. 정의되어있지 않음.
true,false: boolean(0과 1, 참과 거짓)
const a=false; (o)
const a="false"; (x)
boolean 큰따음표 안됨.
3. array,리스트
3-1) const daysOfWeek=["mon","tue","wed","thu","fri"];
* 리스트: 모든 요소가 같은 의미를 가짐. 그러니까 이 리스트는 요일임. 더 설명할 필요 x
* 대괄호 씀
* 대괄호 안에 string,boolean,null,숫자 들어갈 수 있음
3_2) console.log(daysOfWeek[0]);
>배열의 첫번째 출력
3_3) toBuy.push("sat");
>요소 한 개 추가
3_4) toBuy[2]="meat";
>요소 한 개 바꿔주기
4. object
4-1) const player = {
name:"nico",
points:10,
fat:true
};
>대괄호 안에 있는 name,points,fat들이 property, 즉 요소.
4-2)
console.log(player);
player 출력
console.log(player.name);
player라는 object 에서 name 출력
4-3) change.
player=false; >const가 boolean이 되는 거니까. 에러 뜸. const 자체를 바꿀 수는 x
player.fat=false; >const 안에 무언가를 업데이트 할 때는 에러x.
4-4) add.
player.lastName="potato";
object에 요소 추가
여기서 lastName은 없던거임.
4-5) update.
- player.name="nicolas";
object의 속성 변경
- player.points=player.points+15;
값 업데이트