var num = new Number(); // zero, by default
var year = new Number(2024); // integer
var Pi = new Number(3.14); // floating point
var num = 3; // Assign integer
num = 7.713; // Now assign a float number
alert( "Our total is " + (7+5) ); // No memory allocation for variable!
var str = "I learn JavaScript and it's fun";
var num = str.indexOf("n");
alert( num ); // 6 → position index of first 'n'
Tip: you can check for numeric values in variables with the isNaN() function. And you can extract integers or floating points from strings, using parseInt() or parseFloat().