const string1 = "hello"
const string2 = `hello ${string1}`
const number = 123
const pi = .14
toFixed 메서드 : 소수점 n째 자리까지 남김 (string으로 반환)console.log(Number((0.1+0.2).toFixed(1)))true / falseconst fruits = new Array('요소1', '요소2')
const fruits2 = ['요소1', '요소2']
new Array() : 생성자 함수[] : 배열 리터럴fruits[i] fruits.lengthconst user = new Object()
user.name = 'gaji'
user.age = 100
funtion User() {
this.name = 'gaji'
this.age = 100
}
const user = {
name = 'gaji',
age = 100
}
user['name'] , user.nameuser.name : 변수로는 값을 조회할 수 없음const userB = {
name = 'gaji',
age = 100
parent = user
}
userB.user.name , userB['parent']['name'][user, userB]함수 호출 (call) : 함수를 실행 hello()
함수 데이터 자체를 조회 : () 없이 사용 console.log(hello)
JS에서 함수도 자료형이 됨
익명 함수 : getNumber 변수에 함수 데이터 저장
const getNumber = funtion () {
return 123
}
== : Type이 달라도 됨 (사용 권장 X)=== : Type이 같아야 함
false , 0 , null , undefined , NaN , '' , 0ntypeof 데이터[] , {} 의 타입 확인 : .constructornull 의 타입 확인 : Object.prototype.toString.call(data).slice(8, -1)