Notice
Recent Posts
Recent Comments
Link
«   2025/04   »
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30
Archives
Today
Total
관리 메뉴

이수연의 티스토리

[8] React ES6 Ternary Operator 본문

react

[8] React ES6 Ternary Operator

suye0n6 2025. 3. 28. 12:15

Ternary Operator

삼항 연산자는 if / else 와 같은 단순화된 조건 연산자 입니다.

 

Syntax: condition ? <expression if true> : <expression if false>

 

if (authenticated) {
  renderApp();
} else {
  renderLogin();
}

 

삼항 연산자를 사용한 동일한 예는 다음과 같다.

authenticated ? renderApp() : renderLogin();

 

'react' 카테고리의 다른 글

[7] React ES6 Modules  (0) 2025.03.28
[6] React ES6 Spread Operator  (0) 2025.03.28
[5]React ES6 Destructuring  (0) 2025.03.28
[4] React ES6 Array Methods  (0) 2025.03.28
[3]ES6 Variables  (0) 2025.03.28