DEV Community

Raj Maharjan
Raj Maharjan

Posted on

1

Convert string to number

parseInt

Because:

  1. parseInt(n) as name suggests, parses and doesn't simply convert.

Caveats:

  1. For later two, the string should only represent a number otherwise it will return NaN.
  2. However, parseInt("10 apples") can still parse string that starts with a number.

Top comments (0)

Image of Timescale

📊 Benchmarking Databases for Real-Time Analytics Applications

Benchmarking Timescale, Clickhouse, Postgres, MySQL, MongoDB, and DuckDB for real-time analytics. Introducing RTABench 🚀

Read full post →

👋 Kindness is contagious

If you found this post helpful, please leave a ❤️ or a friendly comment below!

Okay