When does 2+2=5? When 2 is 2.49.
A resource for web developers a code snippet library with step by step tutorials.

a resource for web developers...

       

Search Amazon

JavaScript: Maths tutorial code snippet 3.

 

Up Up to JavaScript: Maths overview page

 

 

Number data type: conversion using 'parseFloat()', 'parseInt()' and 'Number()' without the keyword 'new'.

Experiment with using 'minus 0' technique on a string to convert to a number.

Introducing 'typeof()' which returns the type of data that has been passed to it.

Using 'isNaN()' on the data type. Examples of use of above with strings: '42.50', '42.50text' and 'text'.

 





Output view



Back to top

 

Bookmark and Share

 

Copyright © 2006-2010 justfigures.co.uk