온도가 얼마나 변했는지 표시하거나, 섭씨 대신 화씨온도를 표시하고 싶다면 어떻게 해야 할까
요? 템플릿 문자열 안에 표현식을 사용하면 됩니다.
const
roomTempC
=
21
.
5
;
let
currentTempC
=
19
.
5
;
const
message
= `
The
current
temperature
is
` +
`${
currentTempC
-
roomTempC
}\
u00b0C
different
than
room
temperature
.`;
const
fahrenheit
=
`
The
current
temperature
is
${
currentTempC
*
9
/
5
+
32
}\
u00b0F
`;
표현식은 값이므로 값이 들어갈 수 있는 곳에는 어디든 표현식을 쓸 수 있습니다.
5.13
표현식과 흐름 제어 패턴
4
장에서 널리 쓰이는 제어문 패턴 몇 가지를 알아봤습니다. 이제 제어문에 영향을 끼칠 수 있
는 표현식인
3
항 연산자와 단축 평가에 대해 배웠으니 제어문 패턴을 더 알아볼 수 있습니다.
5.13.1
if
...
else
문을 3항 연산자로 ...
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.
O’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
I 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
I’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
I'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.