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

8번째 줄: 8번째 줄:
<source lang='JavaScript'>
<source lang='JavaScript'>
var num = 2/3;
var num = 2/3;
console.log( 100*num.toFixed(2) ); // 67
console.log( 100*num.toFixed(1) ); // 70
console.log( (100*num).toFixed(2) ); // 66.67
console.log( (100*num).toFixed(1) ); // 66.7
</source>
</source>



2017년 7월 5일 (수) 01:05 판

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
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 }}