• String() -> 문자형으로 변환
• Number() -> 숫자형으로 변환
• Boolean() -> 불린형으로 변환
자료형이 다르면 의도치 않은 동작이 발생하기 때문
const mathScore = prompt("수학 몇점?(90)");
const engScore = prompt("영어 몇점?(80)");
const mathScore = (mathScore + engScore) / 2;
console.log(result); -> "4540"
prompt로 입력받은 자료는 문자형임
"9080" / 2 = 4540 그래서 이런 결과출력
근데 어떻게 나누기 2 가 되었는가?
자동 형변환이 돼었기 때문에
console.log(
String(3),
String(true),
String(false),
String(null),
String(undefined),
)
결과

console.log(
Number("1234") -> 숫자 1234 출력
)
console.log(
Number("1234dafdsfg") -> NaN 출력
)
console.log(
Number(true), -> 1 출력
Number(false) -> 0 출력
)
밑에 경우에는 false를 반환하며
나머지는 true를 반환
• 숫자 0
• 빈 문자열 "
• null
• undefined
• NaN
Number(null) -> 0
Number(undefined) -> NaN
Boolean(0) -> false
Boolean('0') -> true
Boolean('') -> false
Boolean(' ') -> true