Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 | 31 |
Tags
- L3 Router
- interrupt
- CPU
- 클린 코드
- ack
- 코드 컴플릿
- L2 switch
- Sector
- Public IP
- 리펙토링
- register
- ALU
- 명령어
- page
- physical address
- 가독성
- 사설 IP
- private ip
- 공인 IP
- refactoring
- Code complete
- MMU
- osi 7
- cache
- Clean code
- float
- TCP
- network
- addressing mode
- floating point
Archives
- Today
- Total
Software Lab
삼항 연산자 본문
function isAdult(age){
if(age >= 18)
return true
else
return false
}
<개선 전>
function isAdult(age){
return (age >= 18) ? true : false
}
<개선 후 #1>
function isAdult(age){
return (age >= 18)
}
<개선 후 #2>
간단한 비교 연산의 경우, 삼항 연산자<개선 후 #1>를 사용할 수 있다.
비교 연산 후 결과가 간단하게 true, false라면 더 축약<개선 후 #2>하여 사용할 수 도 있다.
'코드 리펙토링' 카테고리의 다른 글
1을 더하고 빼는 4가지 방법 (0) | 2022.06.29 |
---|---|
토글 (0) | 2022.06.29 |
어떤 이터레이터를 사용해야 하나? (0) | 2022.06.28 |
필수 변수는 생성자 함수를 통하여 (0) | 2022.06.28 |
try 블록 범위 (0) | 2022.06.28 |
Comments