- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What is the difference between parseInt(string) and Number(string) in JavaScript?
parseInt(string)
The parseInt() method parses up to the first non-digit and returns the parsed value.
For example, the following returns 765:
parseInt("765world")
Let’s take another example. The following returns 50:
parseInt(‘50px”);
Number(string)
Number() converts the string into a number, which can also be a float BTW.
For example, the following returns NaN:
Number(“765world”)
The following returns NaN:
Number(“50px”);
Advertisements