To prove safety of the front (front-end entry-Note Series) - Math Object

Math object
  ECMAScript some common mathematical formulas and to an information encapsulated object --Math object to provide a convenient functionality in our computational mathematics, but also provides the object to Complete these properties and methods of calculation
 
Attributes
the console.log ( "natural logarithm in base, i.e., a constant value of e:" , Math.E); 
the console.log ( "natural logarithm of 10:" , Math.LN10); 
the console.log ( NATURAL "2 logarithmic: " , Math.LN2); 
the console.log ( " base 2 logarithm of e: " , by Math.LOG2E); 
the console.log ( " the logarithm to the base 10 of the e :: " , by Math.LOG10E); 
the console.log ( "[pi] value:" , Math.PI); 
the console.log ( "the inverse square root of 2:" , Math.SQRT1_2); 
the console.log ( "square root of 2:" Math.SQRT2);
 
method
console.log ( "Min:", Math.min (1,2,3,4 )); 
the console.log ( "maximum:", Math.max (1,2,3,4 )); 
 
Console. log ( "rounded up:", Math.ceil (3.0000001 )); 
the console.log ( "rounded down:", Math.floor (3.999999999 )); 
the console.log ( "rounded to the nearest integer:", Math. round (345.678 )); 
 
the console.log ( "[0,1) generates a random number range:" , Math.random ());
 // parameters: two parameters are two endpoints, no longitudinal order 
// internal Implementation: the max and min position does not matter, as long as the number is added in front of the rear parentheses can be reduced the number of 
function random1 (min, max) {
     return Math.round (Math.random () * (max-min ) + min); 
} 
the console.log ( "arbitrary integer range to generate a random number:",random1(5,10));
// The first parameter is the total number of possible values, the first parameter is a second possible value 
function random2 (COUNT, firstnum) {
     return Math.floor (Math.random () * COUNT + firstnum) 
} 
the console.log ( "arbitrary integer range to generate a random number:", random2 (6,5 )); 
 
the console.log ( "absolute value:", the Math.abs (-5 )); 
the console.log ( "root:", Math.sqrt (16 )); 
the console.log ( "the second parameter of the power of the first parameter", Math.pow (2,5 )); 
 
// the received parameter values in radians, degrees to radians formula: Math. PI / 180 * angle 
console.log ( "sine", Math.sin, (Math.PI / 180 [90 *)); 
console.log ( "cosine", Math.cos (Math.PI / 180 * 90)) ; 
the console.log ( "tangent", Math.tan (Math.PI / 180 * 45));
 

Guess you like

Origin www.cnblogs.com/AI-fisher/p/11116735.html