Number
The Number object is used to represent numeric data.
Syntax
The syntax for this object is:
new Number(value)//Or
Number(value)
Where:
value specifies the numeric value of the Number object you are creating.
Sample
<?xml version="1.0"?>
<!DOCTYPE vxml PUBLIC "-//Nuance/DTD VoiceXML 2.0//EN"
"http://voicexml.nuance.com/dtd/nuancevoicexml-2-0.dtd" >
<vxml version="2.0">
...
<script>
var prompt;
//Creating a new object.
var classAverage = new Number(76.45645789);
/*Using the toFixed(arg) method to return a fixed length string representation of the Number object. Note that the argument that is passed to the toFixed() method represents the number of digits after the decimal. That means this sample will round the class average to 76 */prompt = "The class average is " + classAverage.toFixed(0);
</script>
...
</vxml>
Properties
This section describes the Number object properties.
The constructor property identifies the function used to create the Number object’s prototype.
The syntax for this property is:
Number.constructor
The MAX_VALUE property specifies the largest positive value (approximately 1.79E+308) ECMAScript will accept below positive infinity.
The syntax for this property is:
Number.MAX_VALUE
The MIN_VALUE property specifies the smallest positive value (approximately 5E-324) ECMAScript will accept above 0.
The syntax for this property is:
Number.MIN_VALUE
The NaN property indicates a value that is Not-a-Number (NaN).
The syntax for this property is:
Number.NaN
The NEGATIVE_INFINITY property is a number that represents a negative infinity value.
The syntax for this property is:
Number.NEGATIVE_INFINITY
The POSITIVE_INFINITY property is a number that represents a positive infinity value.
The syntax for this property is:
Number.POSITIVE_INFINITY
The prototype property is used to add new methods and properties to the Number object.
The syntax for this property is:
Number.prototype.methodNumber.prototype.property
Methods
This section describes the Number object methods.
The toExponential method returns a string representation of a number in exponential notation.
The syntax for this method is:
number.toExponential(num)
Where:
num represents the number of digits that will appear after the decimal point.
The toFixed method returns a fixed-length string representation of the Number object.
The syntax for this method is:
number.toFixed(num)
Where:
num represents the number of digits that will appear after the decimal point.
The toLocaleString method returns a string representation of the Number object, formatted according to the host’s locale.
The syntax for this method is:
number.toLocaleString()
The toPrecision method returns a string representation of the Number object in exponential format.
The syntax for this method is:
number.toPrecision(num)
The toString method returns a string representation of the Number object.
The syntax for this method is:
number.toString()
The valueOf method returns the primitive number value of the specified Number object.
The syntax for this method is:
number.valueOf()