Number.parseFloat

Number.parseFloat() λ©”μ„œλ“œλŠ” 인수λ₯Ό ꡬ문 λΆ„μ„ν•˜κ³  뢀동 μ†Œμˆ˜μ  μ‹€μˆ˜λ₯Ό λ°˜ν™˜ν•œλ‹€. μΈμˆ˜μ—μ„œ 숫자λ₯Ό ꡬ문 뢄석 ν•  수 μ—†μœΌλ©΄ NaN 을 λ°˜ν™˜ν•œλ‹€.

function circumference(r) {
  if (Number.isNaN(Number.parseFloat(r))) return 0;

  return parseFloat(r) * 2.0 *  Math.PI;
}

circumference('4.533432dsfsdf'); // 28.484393333497767
circumference('dkfkdsfksd'); // 0;

Syntax

Number.parseFloat(value)

Parameters

value

λΆ„μ„ν•˜κ³ μž ν•˜λŠ” 값이닀. λ¬Έμžμ—΄μ΄λ‚˜ μˆ«μžμ΄μ–΄μ•Ό ν•œλ‹€.

retrun value

뢀동 μ†Œμˆ˜μ  값이닀. μΈμˆ˜κ°€ 숫자이면 μˆ«μžκ°€ λ°˜ν™˜λœλ‹€. μΈμˆ˜κ°€ λ¬Έμžμ—΄μ΄λ©΄ λ¬Έμžμ—΄μ΄ 숫자둜 ν•΄μ„λ˜μ–΄ κ·Έ κ²°κ³Όκ°€ λ°˜ν™˜λœλ‹€. μΈμˆ˜κ°€ 해석 ν•  수 μ—†λŠ” 숫자일 경우, NaN 을 λ°˜ν™˜ν•œλ‹€.

Description

Number.parseFloat() λ©”μ„œλ“œλŠ” μ „μ—­ parseFloat() ν•¨μˆ˜μ™€ 같은 κΈ°λŠ₯을 κ°€μ§€κ³  μžˆλ‹€.

Number.parseFloat() λŠ” ECMAScript 2015μ—μ„œ μ „μ—­ λ²”μœ„μ˜ λͺ¨λ“ˆν™”λ₯Ό μœ„ν•΄ μΆ”κ°€λ˜μ—ˆλ‹€.

Polyfill

Browser compatibility

IE μ§€μ›μ•ˆλ¨

Last updated

Was this helpful?