JS-101-Fundamentals
  • JavaScript Library
  • 1-JavaScript Fundamentals
    • 0-Getting Started
      • Welcome
    • 1-JS-Fundamentals
      • 1-Grammar and Types
        • Comments
        • Declarations
        • Scope
        • Hoisting
        • Types
        • Literals
      • 2-Control Flow and Error Handling
        • if
        • if else
        • switch
        • try catch
        • throw
      • 3-Loops
        • For Loops
        • For In Loops
        • For Of Loops
        • Do While
        • While Loops
      • 4-Functions
        • Declarations
        • Expressions
        • Calling Functions
        • Scope
        • Parameters
        • Arguments
        • Closures
        • Closures Challenge
        • Arrow Functions
        • Predefined
      • 5-Expressions and Operators
        • Assignment
        • Comparison
        • Ternary
        • Typeof
        • Left Hand Side
        • Spread
      • 6 Numbers and Dates
        • Numbers
          • Numbers Enhanced
        • Math
        • Dates
      • 7 String Methods
        • String Literals
        • Methods
      • 8 Regular Expressions
        • Basic Intro
      • 9 Arrays
        • Array Review
        • Populating/Referring
        • Length
        • Iterating
        • Methods
      • 10 Objects
        • About Objects
        • Properties
        • Enumeration
        • Initializers
        • Constructor Functions
        • this
        • create
        • Methods
      • 11 ES6 Intro
        • ES6 Intro
        • let
        • const
Powered by GitBook
On this page
  1. 1-JavaScript Fundamentals
  2. 1-JS-Fundamentals
  3. 6 Numbers and Dates

Math

JavaScript has a built-in Math object that has properties and methods that perform mathematical constants and functions.

Here is a list of built-in methods for the Math object (Note: this is not an exhaustive list):

// Math methods

Math.abs() // Absolute value
Math.sin(), Math.cos(), Math.tan() // Standard trigonomic functions, with the argument in radians
Math.asin(), Math.acos(), Math.atan(), Math.atan2() // Inverse trigonomic functions; returns values in radians
Math.sinh(), Math.cosh(), Math.tanh() // Hyperbolic functions; arguments in hyperbolic angle
Math.asinh(), Math.acosh(), Math.atanh() // Inverse hyperbolic functions; returns values in huperbolic angles
Math.pow(), Math.exp(), Math.exmpl(), Math.log10(), Math.log1p(), Math.log2() // Exponential and logarithmic functions
Math.floor(), Math.ceil() // Returns the largest/smallest integer less/greater than or equal to an argument
Math.min(), Math.max() // Returns the minimum/maximum value of a comma-separated list of numbers as arguments
Math.random() // Returns a random number between 0 and 1
Math.round(), Math.fround(), Math.trunc() // Rounding and truncation functions
Math.sqrt(), Math.cbrt(), Math.hypot() // Square root/cube root/square root of the sum of square arguments
Math.sign() // The sign of a number, indicating whether the number is positive, negative, or zero

Unlike many other objects, you CANNOT create a Math object of your own.

PreviousNumbers EnhancedNextDates

Last updated 7 years ago