toFixed

    [js] toFixed() 메서드

    toFixed() 메서드 숫자를 고정 소수점 표기법(fixed-point-notation)으로 표시 Number 인스턴스의 소수 부분 자릿수를 전달받은 값으로 고정한 후, 그 값을 문자열로 반환 function financial(x) { return Number.parseFloat(x).toFixed(2); } console.log(financial(123.456)); // Expected output: "123.46" console.log(financial(0.004)); // Expected output: "0.00" console.log(financial('1.23e+5')); // Expected output: "123000.00" 구문 numObj.toFixed([소수 부분의 자릿수]) 매개변수..