JAVASCRIPT NATIVE OBJECTS-MATH OBJECT PAGE(1)

JavaScript Native Objects:

  • JavaScript has several built-in or native objects.
  • These objects are accessible anywhere in your program and will work the same way in any browser running in any operating system.

List of all important JavaScript Native Objects:
·         JavaScript Number object
·         JavaScript Boolean object
·         JavaScript String object
·         JavaScript  Array object
·         JavaScript Date object
·         JavaScript Math object
·         JavaScript RegExp object

JavaScript Math object:

  • The math object provides you properties and methods for mathematical constants and functions
  • Math is not a constructor. All properties and methods of Math are static and can be called by using Math as an object without creating it.

Syntax:

Math.function name

Example:

var pi_val = Math.PI;
var sine_val = Math.sin(30);

Math Properties:

Property
Description
E
Euler's constant and the base of natural logarithms, approximately 2.718.
SYNTAX: Math.E
EXAMPLE: var A = Math.E
OUTPUT:A= 2.718281828459045 
LN2
Natural logarithm of 2, approximately 0.693.
SYNTAX: Math.LN2
EXAMPLE: var A = Math.LN2
OUTPUT: A=0.6931471805599453 
LN10
Natural logarithm of 10, approximately 2.302.
SYNTAX: Math.LN10
EXAMPLE: var A = Math.LN10
OUTPUT: A=2.302585092994046
LOG2E
Base 2 logarithm of E, approximately 1.442.
SYNTAX: Math.LOG2E
EXAMPLE: var A = Math.LOG2E
OUTPUT: A=1.4426950408889633 
LOG10E
Base 10 logarithm of E, approximately 0.434.
SYNTAX: Math.LOG10E
EXAMPLE: var A= Math.LOG10E
OUTPUT:A=0.4342944819032518 
PI
Ratio of the circumference of a circle to its diameter, approximately 3.14159.
SYNTAX: Math.PI
EXAMPLE: var A = Math.PI
OUTPUT: A=3.141592653589793 
SQRT1_2
Square root of 1/2; equivalently, 1 over the square root of 2, approximately 0.707.
SYNTAX: Math.SQRT1_2
EXAMPLE: var A= Math.SQRT1_2
OUTPUT: A=0.7071067811865476 
SQRT2
Square root of 2, approximately 1.414.
SYNTAX: Math.SQRT2
EXAMPLE: var A = Math.SQRT2
OUTPUT: A=1.4142135623730951 

No comments:

Post a Comment