js에서 number를 출력하면 기본적으로 소수점이 0일때는 버리고 출력됩니다
소수점을 출력할 땐 toFixed로 소수점 자릿수를 지정해주면 됩니다
ex)
const n = 4.0;
console.log(n); //4
console.log(n.toFixed(1)); // 4.0
'프로그래밍 > JS,TS' 카테고리의 다른 글
[개념깨기] collection in javascript (0) | 2023.07.05 |
---|---|
[TypeORM]Error: getaddrinfo ENOTFOUND (0) | 2023.05.09 |
[JS] callback함수 결과값 return (0) | 2023.05.08 |
[JS] jquery로 iframe 내부 tag접근 (0) | 2023.05.08 |
[JS] Assignment to constant variable. (0) | 2023.04.23 |