삼항 조건 연산자
조건식 ? 실행문1 : 실행문2;
<script type="text/javascript">
var age = 29;
var canDrinkAlcohol = (age > 19) ? "True, over 19" : "False, under 19";
document.write(canDrinkAlcohol);
</script>
[JavaScript] LocalStorage (0) | 2020.07.19 |
---|---|
[Javascript] event.preventDefault / preventDefault란? (0) | 2020.07.16 |
[JavaScript ]요소 추가하기 (createElement,TextNode, appendChild) (0) | 2020.07.16 |
[Javascript] classList(add, remove, contains, toggle) (0) | 2020.07.15 |
[Javascript] setInterval, setTimeout (0) | 2020.07.14 |