- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
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”);
- Related Articles
- What is the difference between String and string in C#?
- What is the difference between a string and a byte string in Python?
- What is the difference between String s1 = "Hello" and String s1= new String("Hello") in java?
- What is the difference between a String object and a String literal in Java?
- What is the difference between character literals and string literals in Java?
- What is the difference between a mutable and immutable string in C#?
- What is the role of parseInt() method in JavaScript?
- Difference between String buffer and String builder in Java
- How to convert a string into an integer without using parseInt() function in JavaScript?
- Difference between String and StringBuffer.
- What is the difference between a String object and a StringBuffer object in java?
- What is the difference between String, StringBuffer and StringBuilder classes in Java explain briefly?
- Difference between numbers and string numbers present in an array in JavaScript
- Difference between string and StringBuffer in Java.
- Difference between String and StringBuilder in C#

Advertisements