Skip to Content
이펙티브 타입스크립트
book

이펙티브 타입스크립트

by Dan Vanderkam, Won Ho Jang
November 2021
Intermediate to advanced
364 pages
9h 52m
Korean
Insight
Content preview from 이펙티브 타입스크립트
TypeScript
7
아이템 1 타입스크립트와 자바스크립트의 관계 이해하기
은 타입 체크에서 오류가 발생하지 않도록 신경을 쓰며 타입스크립트 코드를
작성하기 때문입니다.
타입스크립트 타입 시스템은 자바스크립트의 런타임 동작을 ‘모델링’합니다.
런타임 체크를 엄격하게 하는 언어를 사용해 왔다면 다음 결과들이 꽤 당황스
럽게 느껴질 수 있습니다. 예를 들어, 다음 프로그램을 보겠습니다.
const x
=
2 + '3'; //
정상
, string
타입입니다
.
const y
=
'2' + 3; //
정상
, string
타입입니다
.
이 예제는 다른 언어였다면 런타임 오류가 될 만한 코드입니다. 하지만 타입스
크립트의 타입 체커는 정상으로 인식합니다. 두 줄 모두 문자열
"23"
이 되는 자
바스크립트 런타임 동작으로 모델링됩니다.
반대로 정상 동작하는 코드에 오류를 표시하기도 합니다. 다음은 런타임 오
류가 발생하지 않는 코드인데, 타입 체커는 문제점을 표시합니다.
const a
=
null + 7; //
자바스크립트에서는
a
값이
7
이
됩니다
.
// ~~~~ '+'
연산자를
...
형식에
적용할
수
없습니다
.
const b
=
[] + 12; //
자바스크립트에서는
b
값이
‘12’
가
됩니다
.
// ~~~~~~~ '+'
연산자를
...
형식에
적용할
수
없습니다
.
alert('Hello', ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

러닝 타입스크립트

러닝 타입스크립트

조시 골드버그
고성능 파이썬(2판)

고성능 파이썬(2판)

오현석, 미샤 고렐릭, 이안 오스발트
타입스크립트 프로그래밍

타입스크립트 프로그래밍

Boris Czerny, U Jung Eun

Publisher Resources

ISBN: 9788966263134