/**
* concat은 String, Array 둘다에 있음
* 값 타입이 배열이면 Array.concat()이 선택되고, 문자열이면 String.concat() 호출됨
* => 즉 데이터 타입에 따라 오브젝트가 결정된다. (자바스크립트 특징)
*/
let sentenceOne = "hello world".concat(" test")
let sentenceTwo = ["hello", " ", "world"].concat([" test"])
let sentenceThree = "hello world".concat([" test"])
console.log(
typeof sentenceOne + " : " + sentenceOne,
typeof "hello world" + " : " + "hello world",
typeof " test" + " : " + " test")
console.log("--------------------------")
console.log(
Array.isArray(sentenceTwo) + " : " + sentenceTwo,
Array.isArray(["hello", " ", "world"]) + " : " + ["hello", " ", "world"],
Array.isArray([" test"]) + " : " + [" test"])
console.log("--------------------------")
console.log(
typeof sentenceThree + " : " + sentenceThree,
typeof "hello world" + " : " + "hello world",
Array.isArray([" test"]) + " : " + [" test"])
console.log("--------------------------")
QQ. concat에서 형변환 어떻게 하는지
QQ. typeof 연산자 어떻게 동작하지? (primitive만 가능한건가 했는데 그건 또 아닌 것 같고(function은 판별 해준다), Number.isNaN(), Array.isArray().. 얘네는 왜 이걸로 판별해야하는지)