Skip to content

JavaScript parseLong | Code

  • by

JavaScript do not provide parseLong() function. You can use the parseFloat() method, Int in javascript is a float since JavaScript has only one number type.

JavaScript parseLong

Simple example code.

<!DOCTYPE html>
   var myInt = parseInt("10.256"); 

   var myFloat = parseFloat("10.256"); 



JavaScript parseLong

JavaScript has a Number the type which is a 64-bit floating point number*.

If you’re looking to convert a string to a number, use

  1. either parseInt or parseFloat. If using parseInt, I’d recommend always passing the radix too.
  2. use the Unary + operator e.g. +"123456"
  3. use the Number constructor e.g. var n = Number("12343")

*there are situations where the number will internally be held as an integer

Do comment if you have any doubts or suggestions on this Js code.

Note: The All JS Examples codes are tested on the Firefox browser and the Chrome browser.

OS: Windows 10

Code: HTML 5 Version

Leave a Reply

Your email address will not be published. Required fields are marked *