• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
seegatesite header

Seegatesite.com

Seegatesite.com - Programming Tutorial , Sharing , How and Learn Together

  • TOOLS
    • Bootstrap Navbar Online Generator
    • Customize Sidebar Menu Bootstrap 3
    • Bootstrap Demo
  • ADVERTISE
  • CATEGORIES
    • Android
    • Blogging Tips
    • Database
    • CSS
    • Info Gadget
    • Javascript
    • Linux
    • PHP
    • Various
    • WordPress
  • Q&A
  • PHP
  • JAVASCRIPT
  • JQUERY
  • ANGULAR
  • WORDPRESS
  • SEO
  • REACT
🏠 » Javascript » The Most Frequently Used Javascript Math Objects

The Most Frequently Used Javascript Math Objects

By Sigit Prasetya Nugroho ∙ July 13, 2019 ∙ Javascript ∙ Leave a Comment

Share : TwitterFacebookTelegramWhatsapp

Complete guides to Javascript Math Objects. Javascript has a builtin object that can be used to performing mathematical calculations. You don’t need to create some formula and functions manually to do the calculations that already have standardization.

For example, to get an absolute/positive value on a negative number, You can use Math.abs() function to return the positive number. In this Javascript tutorial, I will provide a complete reference to the most frequently used Math objects in Javascript and how to use it in the application.

Table of Contents

  • 1 What is the Javascript Math Object?
  • 2 List of Javascript Objects Math functions and constants
    • 2.1 Calculation of logarithms, powers of numbers and Javascript exponentials
    • 2.2 Trigonometric calculations
    • 2.3 Javascript Rounding Function
    • 2.4 Javascript Root Function
    • 2.5 JS function to return the absolute number
    • 2.6 Javascript object math function to find the highest and lowest numbers
    • 2.7 Javascript random function
  • 3 Conclusion

What is the Javascript Math Object?

The Most Frequently Used Javascript Math Objects

The Math object is a Javascript object that contains mathematical functions and some constants to do accurate calculations like sin, cos, tan, exponent, square root.

The Math JavaScript object is different from the JavaScript operator. Object math aims to shorten formulas and calculations rather than using Javascript operators. (I have discussed Javascript operators, please read the Javascript operator tutorial)

Here is a list of functions of the Javascript Math object that often used

Related Articles :

  • Tutorial Read And Write CSV File With Javascript
  • Tutorial Javascript Asynchronous, Callbacks ,and Promise
  • Best Way To Learn And Adept Javascript AJAX Quickly

List of Javascript Objects Math functions and constants

Calculation of logarithms, powers of numbers and Javascript exponentials

Math.log(x)

Used for calculating logarithmic operations.

Example:

1
Math.log(4)

Javascript Math Object Logarithmic Operations. Min

Math.pow()

The function used to calculate the power of numbers

Example

1
Math.pow(2,3)

Calculate The Power Of Numbers Object Math Javascript Min

Math.exp()

Used to calculate exponential formulas.

Example:

1
Math.exp(1)

Javascript Math Exponential Operation Min

Trigonometric calculations

Math.acos(x)

Returns the cosine arc between the value 0 and pi in radians

Example:

1
Math.acos(0.7)

Math.asin(x)

Returns the arcsine of x (x in radians)

Example:

1
Math.asin(0.3)

Math.atan(x)

Used to return the arctangent of x as a numerical value between pi/2 and pi/2 radians

Example:

1
Math.atan(0.5)

Math.atan2(y,x)

Javascript Math object to return the arctangent of the result for an argument

Example:

1
Math.atan2(2,4)

Math.cos(x)

Javascript object to return cosine of x (x in radians)

Example:

1
Math.cos(0.5)

Math.sin()

Used to return a sine of x (x is radians)

Example:

1
Math.sin(10)

Math.tan(x)

Used to return the tangent value from an angles in radians

Example:

1
Math.tan(0.5)

javascript math object example program

Javascript Rounding Function

Math.round(x)

Used to round numbers to the nearest integer number:

Example:

1
Math.round(2.3)

Math.floor(x)

Used for round down integer values

Example:

1
Math.floor(1.8)

Math.ceil(x)

Used for round up integer values

Example:

1
Math.ceil(4.1)

Javascript Math Object W3schools Round Integer

Javascript Root Function

Math.sqrt(x)

Javascript function to return square root of x

Example:

1
Math.sqrt(64)

Math.cbrt(x)

The Javascript function to return a cubic root of x

Example:

1
Math.cbrt(27)

Javascript Math Object Example Square Roots

JS function to return the absolute number

Math.abs(x)

Used to return the absolute number of x

Example:

1
Math.abs(-44)

Javascript Math Object Reference Absolute Number

Javascript object math function to find the highest and lowest numbers

Math.max(x,y,z,…,n)

Used to return a number with the highest value

js examples:

1
Math.max(2,5,7,8)

Math.min(x,y,z,…,n)

Used to return a number with the lowest value

Example:

1
Math.min(2,5,7,8)

Javascript Math.max Object

Javascript random function

Math.random()

used to return random numbers between 0.0 to 1

Example:

1
Math.random()

Javascript Random Integer Value

In addition to the Math object function, Javascript also has constant math/ math property objects like pi, LN10, E

 Math.Ereturns Eulers Constant
 Math.PIreturns Javascript math object pi
 Math.SQRT2returns the square root of 2
 Math.SQRT1_2returns the square root of 1/2
 Math.LN2returns the natural logarithm of 2
 Math.LN10returns the natural logarithm of 10
 Math.LOG2Ereturns base 2 logarithms of E
 Math.LOG10Ereturns base 10 logarithms of E

 

Conclusion

  • Math objects are objects that are specifically used for mathematical calculations or operations.
  • You will use it a lot in making programs that require mathematical calculations.

So the tutorial for learning JavaScript properties and methods in Math Objects, hopefully easy to understand.

To be good at Javascript in a short period, please read the complete Javascript tutorial articles

Another Javascript Related Post :

  • React-Table Not Updating or Refreshing Data, The Solution ?
  • How To Custom React Datepicker In Bootstrap
  • Tutorial Create Simple POS Using ReactJS And Laravel Lumen Part 1
  • Adept Using Datatables Plugin In 10 Minutes For Beginners (Tutorial)
  • The Using Of Reactstrap And React-Table, Suitable For Beginners
  • Tutorial Create Simple Block UI Using React JS

Avatar for Sigit Prasetya Nugroho

About Sigit Prasetya Nugroho

This site is a personal Blog of Sigit Prasetya Nugroho, a Desktop developer and freelance web developer working in PHP, MySQL, WordPress.

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Primary Sidebar

Welcome to my Home,

Avatar for Sigit Prasetya NugrohoThis site is a personal Blog of Sigit Prasetya Nugroho, a Desktop developer and freelance web developer working in PHP, MySQL, WordPress.



Popular Articles

Checked checkbox AdminLTE Bootstrap in Jquery

November 4, 2014 By Sigit Prasetya Nugroho 7 Comments

Simple create date format validation with jqueryUI

December 21, 2014 By Sigit Prasetya Nugroho Leave a Comment

Create Simple Progress Bar for Fake Online Generator with Jquery

January 10, 2015 By Sigit Prasetya Nugroho Leave a Comment

22+ Coolest Free Jquery Plugin For Premium Theme

October 3, 2015 By Sigit Prasetya Nugroho Leave a Comment

Easy Build Your Anti Copy Paste Plugin

October 6, 2015 By Sigit Prasetya Nugroho Leave a Comment

Popular Tags

adminlte (15) adsense (13) adsense tips (4) affiliate amazon (13) amazon (12) Android (8) angular (16) angular 4 (12) angular 5 (4) asin grabber (3) Bootstrap (27) codeigniter (5) create wordpress theme (5) crud (8) css (6) free wordpress theme (7) google adsense (4) imacros (4) increase traffic (6) jquery (34) laravel (10) laravel 5 (5) learn android (5) lumen api (4) modal dialog (5) mysql (6) nodeJs (4) optimize seo (4) pdo (6) php (30) plugin (53) pos (8) Publisher Tips (5) react (6) Reactjs (9) SEO (37) theme (17) tutorial angular (5) tutorial angular 4 (6) tutorial javascript (10) tutorial javascript beginners (4) twitter (3) wordpress (18) wordpress plugin (13) XMLRPC (5)




  • About
  • Contact Us
  • Disclaimer
  • Privacy Policy
  • Terms and Conditions

©2022 Seegatesite.com