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

(새 문서: ==개요== ==JavaScript== {{참고|JavaScript toFixed()}} <source lang='JavaScript'> console.log( (5).toFixed(2) ); // 5.00 console.log( (5.1234).toFixed(2) ); // 5.12 console.log(...)
 
잔글 (봇: 자동으로 텍스트 교체 (-</source> +</syntaxhighlight>, -<source +<syntaxhighlight ))
 
(다른 사용자 한 명의 중간 판 5개는 보이지 않습니다)
1번째 줄: 1번째 줄:
==개요==
==개요==
;JavaScript toFixed()
<syntaxhighlight lang='JavaScript'>
console.log( (5).toFixed(2) ); // 5.00
console.log( (5.1234).toFixed(2) ); // 5.12
console.log( (5.99999).toFixed(2) ); // 6.00


==JavaScript==
console.log( (1000.1234).toFixed(2) ); // 1000.12
{{참고|JavaScript toFixed()}}
</syntaxhighlight>
 
<syntaxhighlight lang='JavaScript'>
<source lang='JavaScript'>
var num = 2/3;
console.log( (5).toFixed(2) );
console.log( 100*num.toFixed(1) ); // 70
// 5.00
console.log( (100*num).toFixed(1) ); // 66.7
console.log( (5.1234).toFixed(2) );
</syntaxhighlight>
// 5.12
console.log( (5.99999).toFixed(2) );
// 6.00
</source>


==같이 보기==
==같이 보기==
18번째 줄: 19번째 줄:
* [[JavaScript toPrecision()]]
* [[JavaScript toPrecision()]]
* [[JavaScript toString()]]
* [[JavaScript toString()]]
* [[함수 toFixed()]]
* [[함수 round()]]
* [[함수 round()]]
* [[함수 number_format()]]
* [[함수 number_format()]]

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