JavaScript e Ajax

Page 221

Appendix A: JavaScript Objects

Math Object Properties Property E LN2 LN10 LOG2E LOG10E PI SQRT1_2 SQRT2

Description Returns Euler’s number, the base of the natural logarithm (approx. 2.718) Returns the natural logarithm of 2 (approx. 0.693) Returns the natural logarithm of 10 (approx. 2.302) Returns the base-2 logarithm of E (approx. 1.442) Returns the base-10 logarithm of E (approx. 0.434) Returns PI (approx. 3.14159) Returns the square root of 1/2 (approx. 0.707) Returns the square root of 2 (approx. 1.414)

Math Object Methods Method abs(x) acos(x) asin(x) atan(x) atan2(y,x) ceil(x) cos(x) exp(x) floor(x) log(x) max(x,y,z,...,n) min(x,y,z,...,n) pow(x,y) random() round(x) sin(x) sqrt(x) tan(x)

Description Returns the absolute value of x Returns the arccosine of x, in radians Returns the arcsine of x, in radians Returns the arctangent of x as a numeric value between –PI/2 and PI/2 radians Returns the arctangent of the quotient of its arguments Returns x, rounded upward to the nearest integer Returns the cosine of x (x is in radians) Returns the value of E to the power of x Returns x, rounded downward to the nearest integer Returns the natural logarithm (base E) of x Returns the number with the highest value Returns the number with the lowest value Returns the value of x to the power of y Returns a random number between 0 and 1 Rounds x to the nearest integer Returns the sine of x (x is in radians) Returns the square root of x Returns the tangent of x (x is in radians)

Number Object The Number object is an object wrapper for primitive numeric values. Number objects are created with new Number(). The syntax is as follows: var num = new Number(value);

207


Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.