1.JavaScript Boolean (Boolean) object
A Boolean (Boolean) object is used to convert a non-Boolean value to a Boolean value (True or false).
1.1 Complete Boolean (Boolean) object reference manual
1.2 Creating a Boolean Object
A Boolean object represents two values: "True" or "false"
The following code defines a Boolean object named Myboolean:
var myboolean=New Boolean ();
If the Boolean object has no initial value or its value is:
- 0
- -0
- Null
- ""
- False
- Undefined
- NaN
Then the value of the object is false. Otherwise, its value is true, even when the value of the variable is the string "false"!
2.JavaScript Math (Arithmetic) object
The Math object works by performing common arithmetic tasks.
2.1 Complete Reference manual for Math objects
2.2Math objects
The Math object works by performing normal arithmetic tasks.
The Math object provides a variety of arithmetic value types and functions. You do not need to define it before using this object.
var x=Math.PI; var y=math.sqrt (+);
2.3 Calculation value
JavaScript provides 8 arithmetic values that can be accessed by the Math object:
You can refer to the following JavaScript constants using this method:
Math.EMath.PIMath.SQRT2Math.SQRT1_2Math.LN2Math.LN10Math.LOG2EMath.LOG10E
2.4 Arithmetic methods
In addition to the arithmetic values that can be accessed by the Math object, there are several functions (methods) that can be used.
The following example rounds a number by using the round method of the Math object.
document.write (Math.Round (4.7));
The above code output is: 5
The following example uses the random () method of the Math object to return an arbitrary number between 0 and 1:
document.write (Math.random ());
The above code output is:
0.6671303459705329
The following example uses the floor () method and random () of the Math object to return a random number between 0 and 11:
document.write (Math.floor (Math.random ()));
The above code output is: 5
JavaScript Boolean (Boolean) object