Javascript JS 형변환
String() console.log( String(3), String(true), String(null), String(undefined) ) Number() console.log(Number("1234"), Number(true), Number(false), Number("1234asdf456")); Boolean() true console.log(Boolean(1), Boolean(123), Boolean("Javascript")); false console.log(Boolean(0), Boolean(""), Boolean(null), Boolean(undefined), Boolean(NaN));
타입스크립트 Typescript 제네릭
Typescript // Generic function getSize(arr: T[]): number { return arr.length; } const arr1 = [1, 2, 3]; getSize(arr1); const arr2 = ["1", "2", "3"]; getSize(arr2); interface Mobile { name: string; price: number; option: T; } const m1: Mobile = { name: "s21", price: 1000, option: { color: "red", coupon: false, } } const m2: Mobile = { name: "s20", price: 900, option: "good" } interface User { nam..