// Type Conversion
console.log("Before Type Conversion");
console.log("10"+"5");
console.log(10+5);
console.log("After Type Conversion");
console.log(Number("10")+ Number("5"));
console.log(String(10)+String(5));
// number --> String
let x = 123;
console.log(x);
console.log(typeof x); // number
console.log(String(x));
console.log(typeof String(x)); // string
// boolean --> String
let y = true;
console.log(y); // true
console.log(typeof y); // boolean
console.log(String(y));
console.log(typeof String(y)); // string
// string --> boolean
let a = "문자";
console.log(a);
console.log(typeof a); // string
console.log(Boolean(a)); // true 만약 a가 "" 이면 false
console.log(typeof Boolean(a)); // boolean
// number --> boolean
let b = 123;
console.log(b);
console.log(typeof b); // number
console.log(Boolean(b)); // true 만약 b가 0 또는 NaN 이면 false
console.log(typeof Boolean(b)); // boolean
console.log(Number('1' + '2' + '3') - Number(true));
// Number(true) >> 1 , Number(false) >> 0
// console.log(123-1) >> 122
/* 자동으로 Type conversion이 되는 JS
*/
console.log(4 + '2'); // 42
console.log(4 + 2); // 6
console.log(4 - true); // 4-1 >> 3
console.log(4 * false); // 4 * 0 >> 0
console.log(4 / '2'); //2
console.log('4' ** true); // 4
console.log(4 % 'two'); // NaN
// 관계 비교 연산
console.log(2 < '3'); // true
console.log(2 > True); // true
console.log('2' <= false); // false
console.log('two' >= 1);
// false
// two가 NaN이 되어서
/*
===, !== 는 value와 data type도 check
==, !=는 value만 check
*/
console.log( 1 === "1"); // false
console.log( 1 === true); // false
console.log( 1 == "1"); // true
console.log( 1 == true); // true
console.log(typeof ('4' + 3));
/*
더하기 연산은 피연산자가 한쪽이라도 문자열이 있을 경우
양쪽 모두를 문자열로 형 변환한 다음 문자열 덧셈을 연산
따라서 typeof ("43") >> string
*/
console.log(typeof (3 - true));
/*
더하기 기호를 제외한 일반적인 산술연산자들은
연산 되는 값들을 모두 숫자형으로 변환한 다음 연산한당
typeof(3-1); >> number
*/
console.log(typeof (Boolean(5) * true));
/*
typeof (true * true) >> typeof (1) >> number
*/
console.log(typeof (true < false));
/*
typeof false >> boolean
*/