JavaScript Tutorial

Español Français 中文 Deutsch Portuguese Japanese nederlands
Java-Script Tutorial
Introduction Introduction
Variables Variables
Operators Operators
Statements Statements
Loops Loops
Functions Functions
Objects Objects
Arrays Arrays
Cookies JS Cookies
Browser Objects Browser Objects
Form DOM Form DOM
Style Objects DOM Style Objects
Forums Ask Your Doubts
Scraps More about Javascript
Feedback Feedback

Javascript Convert Values

Tutorials Javascript


Converting a string data type to float in javascript?
How to convert a float, interger value to string?


c) Converting String to Float
To convert a value from string to float, we have to use the function or method "parseFloat() to convert a string value to float.

Example Result
parseFloat("4.333"); 4.333
parseFloat("5aaa"); 5
parseFloat("6e2"); 600
parseFloat("aaa"); NaN (means "Not a Number")

d) Converting Integer/Float to String
Integer (int) or float value can be converted to string by using the function or method toString().

Example Result
var a = 3.22;
var a = 5;

Example Code:
<script language="javascript">
var a = 32;
var b = 333;
var c = a.toString()+b;
document.write(" to String function "+c);


A Note
Javascript (JS) is one of the most used languages in the world. Some times spelled as Java Script. Hope you enjoy this tutorial. Do send your feedback or suggestions on this javascript or java script tutorial. This is a copyright content.

Other Links

web hosting