Math object in JavaScript
The Math object gives you properties and methods for constants and mathematical functions. Unlike other Global objects, Math is not a constructor. All properties and methods of Math are static (Static) and can be called using Math as an object without having to create it.
So, you refer to the constant pi as Math.PI and you call the sine function as Math.sin (x) , where x is the parameter of the method.
Syntax
The syntax for calling properties and methods of Math is as follows:
var pi_val = Math . PI ; var sine_val = Math . sin ( 30 );
Math properties
The table below lists the properties of Math and describes it.
Attribute DescriptionE The E constant, and the base of the natural algorithm (symbol: ln), approximately 2.718 LN2 Natural logarithm of 2, approximately 0.693. LN10 Natural logarithm of 10, approximately 2,302. LOG2E Base 2 Logarithm of E, approximately 1,442. LOG10E Logarithm base 10 of E, approximately 0.434. PI Pi coefficient, approximately 3.14159. SQRT1_2 The square root of 1/2; approximately 0.707. SQRT2 The square root of 2, approximately 1,414.Math methods
The table below lists Math's methods and describes it.
Method Descriptionabs () Returns the absolute value of some acos () Returns arccos (radians value) of some asin () Returns arcsin (radians value) of some atan () Returns arctan (value radians) of some atan2 () Returns inverse trigonometric tang ceil () Returns the smallest integer number greater than or equal to a number cos () Returns cos of a number. exp () Returns E, where N is the parameter, and E is the Euler floor constant () Returns the largest integer smaller than or equal to a log number () Returns the base e-logarithm of a maximum number () Returns the maximum number of 0 or more min () Returns the smallest number of 0 or more pow numbers () Returns the value of (base) (exponent) . random () Returns a random number between two numbers 0 and 1. round () Rounds the number. Returns the value of the nearest integer. sin () Returns the sine of some sqrt () Returns the square root of some tan () Returns the tan of some toSource () Returns the "Math" stringAccording to Tutorialspoint
Previous article: Date object in JavaScript
Next lesson: Regular Expression and RegExp in JavaScript
5 ★ | 1 Vote
You should read it
- How to use MathType to write math formulas
- Effective mobile math solutions
- 3 apps to help kids learn Math for free on Windows 10
- Article: 'What to study Math for?' by a leading security expert Google caused a social network storm
- Microsoft adds Math Solver to Edge browser
- math.h in C
- How to Improve Math Skills
- The fastest way to solve online maths
May be interested
- Print pages in JavaScriptmany times you will love to put a button on your website to print the content of that page through a printer. javascript helps you perform this function by using the print function of the window object.
- How to turn on and turn off Javascript on Firefox, Chromejavascript is an object-based scripting language that often creates eye-catching effects on websites.however, if you need to turn on or off javascript, the following article will guide you to do that.
- Regular Expression and RegExp in JavaScripta regular expression is an object that describes a pattern of characters.
- Boolean objects in JavaScriptboolean objects represent two values, either true or false. if the value parameter is omitted either 0, -0, null, false, nan, undefined, or an empty string (), the object has an initial value of false.
- Array (Array) in JavaScriptarray object - array helps you store multiple values in a single variable. it stores a set of fixed-size ranges of elements in the same type (type). an array is used to store a data set, but it is often more useful to think of an array as a collection of variables in the same type.
- What is JavaScript? Can the Internet exist without JavaScript?not everyone knows what javascript is and how it works. the long and fascinating development history of javascript as well as what we can do with javascript is still unknown.
- 11 tips to solve Math simple but extremely interestingif you have difficulty solving simple math problems, then it is not your fault. the problem is that no one teaches you simple but super fast math tips at school. here are 11 simple and extremely interesting math tips.
- What is Currying in Javascript? How to use Currying in JavaScriptthe currying feature in javascript can help you keep your code tidy and give you a new way of seeing how functions work. currying is ideal when you want to break complex logic into smaller, manageable, and self-contained pieces of code.
- Things to know about 'this' in JavaScriptare you having trouble understanding the keyword 'this' in javascript ? then please read what you need to know about 'this' in javascript below.
- Udemy's top 5 JavaScript coursesa programming language that runs on any computer in the world. a language does not need any special software to run. a language ranked among the top in the world.