const : 변하지 않는 데이터 값. 재할당을 하면 에러가 발생함
let : 변하는 데이터 값
const 변수명1 = '값 1';
let 변수명2 = '값 2';
산술 연산자 : + , - , / , * , % , ** , ++ , -- ,
할당 연산자 : =
비교 연산자 : > , < , >= , <= , == , === , != , !==
논리 연산자 :
|| (A || B) : A와 B 둘 중 하나라도 참이면 참
&& (A && B) : A와 B 둘 다 참이여야 참
! (!A) : A가 참이면 거짓, 거짓이면 참
문장, 단어, 알파벳 등 " " 안에 들어가 있는 모든 문자
정수, 음수, 소숫점 등 " " 안에 들어가 있지 않는 숫자.
true, false
선언할 값을 [ ] 이용하여 선언
let fruit = ['바나나', '사과', '포도'];
앞에 있는 값 제거
let fruit = ['바나나', '사과', '포도'];
fruit.shift();
console.log(fruit); // let fruit = ['사과', '포도']
마지막에 있는 값 제거
let fruit = ['바나나', '사과', '포도'];
fruit.pop();
console.log(fruit); // let fruit = ['바나나', '사과']
배열 아이템을 제거내는 역활 (시작점, 끝점)
let fruit = ['바나나', '사과', '포도'];
console.log(fruit.slice(1,2)); // ['바나나', '포도']
배열 아이템을 제거하는 역활 (시작점, 지우고 싶은 갯수)
let fruit = ['바나나', '사과', '포도'];
fruit.splice(1,1)
console.log(fruit); // ['바나나', '포도']
아이템이 있는지 없는지 확인
let fruit = ['바나나', '사과', '포도'];
console.log(fruit.includes('바나나')); // true
console.log(fruit.includes('수박')); // false
아이템의 인덱스 번호를 알려줌
let fruit = ['바나나', '사과', '포도'];
console.log(fruit.includes('바나나')); // 0
선언할 값을 { } 이용하여 선언. { key : value } 로 표현
let banana = {cost : 3000,
color : '노랑'};
console.log(banana) // {cost : 3000, color : '노랑'}
.key 혹은 ['키'] 값으로 object의 value 에 접근할 수 있음
console.log(banana.color) // 노랑
console.log(banana["color"]) // 노랑
object.key = value 값을 통하여 object에 값을 추가 할 수 있음
banana.kor = '바나나';
console.log(banana.kor) // 바나나
banana.color = '초록';
console.log(banana.color) // 초록