পৃষ্ঠাসমূহ

Search Your Article

CS

 

Welcome to GoogleDG – your one-stop destination for free learning resources, guides, and digital tools.

At GoogleDG, we believe that knowledge should be accessible to everyone. Our mission is to provide readers with valuable ebooks, tutorials, and tech-related content that makes learning easier, faster, and more enjoyable.

What We Offer:

  • 📘 Free & Helpful Ebooks – covering education, technology, self-development, and more.

  • 💻 Step-by-Step Tutorials – practical guides on digital tools, apps, and software.

  • 🌐 Tech Updates & Tips – simplified information to keep you informed in the fast-changing digital world.

  • 🎯 Learning Support – resources designed to support students, professionals, and lifelong learners.

    Latest world News 

     

Our Vision

To create a digital knowledge hub where anyone, from beginners to advanced learners, can find trustworthy resources and grow their skills.

Why Choose Us?

✔ Simple explanations of complex topics
✔ 100% free access to resources
✔ Regularly updated content
✔ A community that values knowledge sharing

We are continuously working to expand our content library and provide readers with the most useful and relevant digital learning materials.

📩 If you’d like to connect, share feedback, or suggest topics, feel free to reach us through the Contact page.

Pageviews

Friday, February 17, 2017

ES6 - Math

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

Math Properties

Following is a list of all Math properties and its description.
Sr.No Property & Description
1 E Euler's constant and the base of natural logarithms, approximately 2.718
2 LN2 Natural logarithm of 2, approximately 0.693
3 LN10 Natural logarithm of 10, approximately 2.302
4 LOG2E Base 2 logarithm of E, approximately 1.442
5 LOG10E Base 10 logarithm of E, approximately 0.434
6 PI Ratio of the circumference of a circle to its diameter, approximately 3.14159
7 SQRT1_2 Square root of 1/2; equivalently, 1 over the square root of 2, approximately 0.707
8 SQRT2 Square root of 2, approximately 1.414

Exponential Functions

The basic exponential function is Math.pow(), and there are convenience functions for square root, cube root, and powers of e, as shown in the following table.
Sr.No Function & Description
1 Math.pow(x, y) Returns x raised to the power y
2 Math.sqrt(x) Returns the square root of the number x
3 Math.cbrt(x) This method returns the cube root of a number x
4 Math.exp(x) Equivalent to Math.pow(Math.E, x)
5 Math.expm1(x) Equivalent to Math.exp(x) – 1
6 Math.hypot(x1, x2,...) Returns the square root of the sum of arguments

Logarithmic Functions

The basic natural logarithm function is Math.log (). In JavaScript, “log” means “natural logarithm.” ES6 introduced Math.log10 for convenience.
Sr.No Function & Description
1 Math.log(x) Natural logarithm of x
2 Math.log10(x) Base 10 logarithm of x
3 Math.log2(x) Base 2 logarithm of x
4 Math.log1p(x) Natural logarithm of 1 + x

Miscellaneous Algebraic Functions

Following is a list of miscellaneous algebraic functions with their description.
Sr.No Function & Description
1 Math.abs(x) Absolute value of x
2 Math.sign(x) The sign of x: if x is negative,–1; if x is positive, 1; and if x is 0, 0
3 Math.ceil(x) The ceiling of x: the smallest integer greater than or equal to x
4 Math.floor(x) The floor of x: the largest integer less than or equal to x
5 Math.trunc(x) The integral part of x (all fractional digits are removed)
6 Math.round(x) x rounded to the nearest integer
7 Math.min(x1, x2,...) Returns the minimum argument
8 Math.max((x1, x2,...) Returns the minimum argument

Trigonometric Functions

All trigonometric functions in the Math library operate on radians, not degrees.
Sr.No Function & Description
1 Math.sin(x) Sine of x radians
2 Math.cos(x) Cosine of x radians
3 Math.tan(x) Tangent of x radians
4 Math.asin(x) Inverse sine (arcsin) of x (result in radians)
5 Math.acos(x) Inverse cosine (arccos) of x (result in radians)
6 Math.atan(x) Inverse tangent (arctan) of x (result in radians)
7 Math.atan2(y, x0) Counterclockwise angle (in radians) from the x-axis to the point (x, y)

Math.random()

The Math.random() function returns a pseudorandom number between 0 (inclusive) and 1 (exclusive).

Example: Pseudorandom Number Generation (PRNG)

var value1 = Math.random();  
console.log("First Test Value : " + value1 ); 

var value2 = Math.random();  
console.log("Second Test Value : " + value2 ); 

var value3 = Math.random();  
console.log("Third Test Value : " + value3 ); 

var value4 = Math.random(); 
console.log("Fourth Test Value : " + value4 );

Output

First Test Value : 0.5782922627404332 
Second Test Value : 0.5624510529451072 
Third Test Value : 0.9336334094405174 
Fourth Test Value : 0.4002739654388279

No comments:

Post a Comment