Edit in JSFiddle

//Type Coercion

var x = "123 ABC"; //string
var y = "53.29"; //string
var z = "ABC 123"; //string

var a = 12345; //number
var b = 34.34; //number
var c = "1234.45 789 098 Hello"; //string 
var d = true; //boolean

x = parseInt(x);

console.log("x is of type " + typeof(x));
console.log("y is of type " + typeof(parseFloat(y)));
console.log("z is of type " + typeof(parseInt(z)));
console.log("a is of type " + typeof(String(a)));
console.log("b is of type " + typeof(String(b)));
console.log("c is of type " + typeof(parseFloat(c)));
console.log("d is of type " + typeof(String(d)));
<!-- Easy JavaScript #10 - Intro Type Coercion -->
<p>
JavaScript is a weakly typed scripting language. It means that the variable type can be changed in certain circumstances. This is known as Type Coercion. 
</p>
<p>
If we have the string "10", we can easily coerce this value to be seen as a number, or integer 10 by using either parseInt() or parseFloat(). 
</p>
<p>
If we have a number 1234567, we can coerce this value to be seen as a string, either by using String() or by putting quotes around it and writing "1234567" instead. 
</p>
<p>
You can even turn a boolean, true, into a string! Try String(true);! It's often easier to turn some other variable type into a string than it is to turn a string into something else. 
</p>
<h2>
Rules of parseInt and parseFloat:
</h2>
<ol>
<li>Only the first number in a string is parsed.</li>
<li>Although Spaces are allowed, only the first number will be parsed.</li>
<li>If the first character can't be coerced, then it can't be converted!</li>
</ol>
<p>
Visit <a href="http://www.easyprogramming.net">EasyProgramming.net</a> for more tutorials!
</p>