JavaScript+calculations
JavaScript+calculations
/*
ternary
alert(c ? t : f); // When c is true, there is no reason to evaluate f.
*/
var a = 4;
//--a;
var c = a*3; //9
console.log(c % 2);
var b = (a==5?'yes':'no'); //ternary
var d = Math.floor(Math.random()*1000);
console.log(d);
/*
JavaScript supports the following binary arithmetic operators:
+ addition
- subtraction
* multiplication
/ division (returns a floating-point value)
% modulus (returns the remainder)
JavaScript supports the following unary arithmetic operators:
Assignment
= assign
+= add and assign
-= subtract and assign
*= multiply and assign
/= divide and assign
%= modulus and assign
MATH
The Math object contains various math-related constants (for example, π) and functions (for
example, cosine). (Note that the Math object has no constructor, unlike Array or Date. All its
methods are "static", that is "class" methods.) All the trigonometric functions use angles
expressed in radians, not degrees or grads.
-1-
H:\Websites\Localhost\SourceCode\JavaScript calculations.js Thursday, November 12, 2015 1:54 PM
-2-