타입스크립트(3)
-
[TypeScript] 객체지향 스타벅스
TypeScript 공부 겸 객체를 하나 구성해 보았다. 뻔한 객체는 재미가 없어서 스타벅스를 주제로 Drink 객체와 Coffee 객체를 만들었고 바닐라 라떼를 만들었다. 공들여서 짠 코드도 아니고 예외처리도 없는 재미로 짠 코드이니 그저 재미로 보면 좋을 것 같다. Interface Syrup name : enum(mocha, vanilla, caramel, dolce ...) sugar : boolean count : number Milk ratios : number type : enum(whole, nonfat, 2 percent, soy, coconut, almond) Struct Drink size : enum(tall, grande, venti) type(cold, hot) own_cup :..
2019.09.17 -
[TypeScript] Object, Interface, Class
Object // const는 상수를 지정할 때 사용하지만 Object의 값은 수정할 수 있다. const student = { id : "123456", name : "Kent" }; // 아래 두 방법으로 Object의 값에 접근할 수 있다. student.id = "654321"; student["name"] = "Kevin" console.log(student); // 출력 : { id: '654321', name: 'Kevin' } console.log(student["id"]); // 출력 : 654321 console.log(student.name); // 출력 : Kevin Interface 객체(Object)의 구조를 나타내는 경우 interface Car { door : number; ..
2019.09.14 -
[TypeScript] 타입스크립트 시작하기
Typescript 설치 TypeScript설치및 환경설정 TypeScript설치및 환경설정 https://nodejs.org/en/Current는 앵귤러, 리액트, 등등 혼합해서 같이 사용... blog.naver.com Typescript 컴파일 아래 명령어를 통해 Typescript를 컴파일하고 javascript 형태의 결과를 얻을 수 있다. tsc [File].ts Javascript 실행 작성 한 javascript 파일을 실행하고 결과를 확인할 수 있는 방법은 대표적으로 두 가지가 있다. 하나는 브라우저에서 해당 JS파일을 실행하는 방법과 서버에서 node를 이용하여 실행하는 방법이 있는데 나는 Linux 환경에서 공부를 하고 있으니 node를 이용하여 결과를 확인해 보겠다. node를 이용..
2019.09.01