Latest web development tutorials

JavaScript Tutorial

JavaScript Tutorial JavaScript Introduction JavaScript usage JavaScript Output JavaScript grammar JavaScript Statement JavaScript Notes JavaScript variable JavaScript type of data JavaScript Object JavaScript function JavaScript Scope JavaScript event JavaScript The string JavaScript Operator JavaScript Comparison JavaScript If...Else JavaScript switch JavaScript for JavaScript while JavaScript Break & Continue JavaScript typeof JavaScript Type conversion JavaScript Regular Expressions JavaScript error JavaScript debugging JavaScript Variable promotion JavaScript Strict mode JavaScript Use errors JavaScript Form validation JavaScript Keep the keyword JavaScript JSON JavaScript void JavaScript Code specification

JS function

JavaScript Function definition JavaScript Function parameter JavaScript Function call JavaScript Closure


DOM Introduction DOM HTML DOM CSS DOM event DOM EventListener DOM element

JS Advanced Tutorial

JavaScript Object JavaScript Number JavaScript String JavaScript Date JavaScript Array JavaScript Boolean JavaScript Math JavaScript RegExp Object

JS Browser BOM

JavaScript Window JavaScript Window Screen JavaScript Window Location JavaScript Window History JavaScript Navigator JavaScript Pop-ups JavaScript Timing events JavaScript Cookies

JS Library

JavaScript Library JavaScript test jQuery JavaScript test Prototype

JS Examples

JavaScript Examples JavaScript Object instance JavaScript Browser object instance JavaScript HTML DOM Examples JavaScript to sum up

JS Reference Manual

JavaScript Object HTML DOM Object

JavaScript Math (arithmetic) Object

Role Math (arithmetic) objects is: perform common arithmetic tasks.


Online examples

round ()
How to use the round ().

random ()
How to use the random () to return a random number between 0-1.

max ()
How to use a larger count max () to return the two given. (Before ECMASCript v3, which only two parameters.)

min ()
How to use min () to return the two numbers given in smaller numbers. (Before ECMASCript v3, which only two parameters.)

Complete Math Object Reference

We provide JavaScript Math object reference manual , which includes all properties and methods can be used for arithmetic object.

The manual contains a detailed description and relevant examples for each of the properties and methods.

Math Object

Role Math (arithmetic) objects are: to perform common arithmetic tasks.

Math object provides a variety of types and numerical calculation functions. Before using this object without having to define it.

Use Math attribute / method syntax:

var x = Math.PI;
var y = Math.sqrt (16);

Note: Math object does not use this object before it is defined.

Numerical calculation

JavaScript provides 8 kinds of objects that can be accessed Math Operators values:

You can refer to the following Javascript constant use:


Arithmetic method

In addition to objects that can be accessed Math count value, there are several functions (methods) can be used.

The following example uses the method of the Math object to round a number to round.

document.write (Math.round (4.7));

The code above outputs:


The following example uses the Math object's random () method to return a random number between 0 and 1:

document.write (Math.random ());

The code above outputs:

The following example uses the Math object floor () method and random () to return a random number between 0 and 11, between:

document.write (Math.floor (Math.random () * 11));

The code above outputs: