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

2번째 줄: 2번째 줄:
;JavaScript toFixed()
;JavaScript toFixed()
<source lang='JavaScript'>
<source lang='JavaScript'>
console.log( (5).toFixed(2) );
console.log( (5).toFixed(2) ); // 5.00
// 5.00
console.log( (5.1234).toFixed(2) ); // 5.12
console.log( (5.1234).toFixed(2) );
console.log( (5.99999).toFixed(2) ); // 6.00
// 5.12
</source>
console.log( (5.99999).toFixed(2) );
<source lang='JavaScript'>
// 6.00
var num = 2/3;
console.log( 100*num.toFixed(2) ); // 67
console.log( (100*num).toFixed(2) ); // 66.67
</source>
</source>



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

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(2) ); // 67
console.log( (100*num).toFixed(2) ); // 66.67

2 같이 보기

3 같이 보기

4 참고

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