"JavaScript toFixed()"의 두 판 사이의 차이

잔글 (봇: 자동으로 텍스트 교체 (-</source> +</syntaxhighlight>, -<source +<syntaxhighlight ))
 
1번째 줄: 1번째 줄:
==개요==
==개요==
;JavaScript toFixed()
;JavaScript toFixed()
<source lang='JavaScript'>
<syntaxhighlight lang='JavaScript'>
console.log( (5).toFixed(2) ); // 5.00
console.log( (5).toFixed(2) ); // 5.00
console.log( (5.1234).toFixed(2) ); // 5.12
console.log( (5.1234).toFixed(2) ); // 5.12
7번째 줄: 7번째 줄:


console.log( (1000.1234).toFixed(2) ); // 1000.12
console.log( (1000.1234).toFixed(2) ); // 1000.12
</source>
</syntaxhighlight>
<source lang='JavaScript'>
<syntaxhighlight lang='JavaScript'>
var num = 2/3;
var num = 2/3;
console.log( 100*num.toFixed(1) ); // 70
console.log( 100*num.toFixed(1) ); // 70
console.log( (100*num).toFixed(1) ); // 66.7
console.log( (100*num).toFixed(1) ); // 66.7
</source>
</syntaxhighlight>


==같이 보기==
==같이 보기==

2020년 11월 2일 (월) 02:51 기준 최신판

1 개요[ | ]

JavaScript toFixed()
console.log( (5).toFixed(2) ); // 5.00
console.log( (5.1234).toFixed(2) ); // 5.12
console.log( (5.99999).toFixed(2) ); // 6.00

console.log( (1000.1234).toFixed(2) ); // 1000.12
var num = 2/3;
console.log( 100*num.toFixed(1) ); // 70
console.log( (100*num).toFixed(1) ); // 66.7

2 같이 보기[ | ]

3 같이 보기[ | ]

4 참고[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}