A simple calculation command Evalvar str= "6*5"; Alert (eval (str));Note:Not safe, generally not to use two, id&&name
- ID: can only be unique
- Name: can have multiple, can be used in the array
three, apply for a global variablevar application, even if you do not assign a value to give a null valueFour, Array
- Array declarations
- Usual declaration method: var arr = new Array (1,2,3,4,5);
- array abbreviation, direct amount, inside can store various objects var arr = [];
- var arr=new Array (); and Var arr=[]; The difference
- var arr=new Array (); When a pure number, represents the defined array length
- var arr=[]; A pure number is a new member that is added to the array.
Five, Console.log (Math)Print log all mathematical formulas in console console math come outSix, Random ()
- randomly generates a random number with a range of 0~1, excluding 0 and 1
- var num = Math.random ();
Seven, taking random numbers within a specific rangefunction Fnrand (min, max) {return parseint (Math.random () * (max-min)) + min;}Eight, Random function round ()
- var rand = Math.Round (Math.random ());
- Function: Allows to randomly fetch 0 and 1
Nine, Cycle
- while () {} know the condition of Loop end
- For knowing the number of cycles
10Timer
- One timer, can be used to delay
- SetTimeout (function () {}, 1000);
- Loop timer
- SetInterval (function () {}, 1000);
- Clear Timer
- First give the timer a name to differentiate
- Re-clearinterval (timer name);
- Note : Timers are usually off and on, non-global timers Odiv.timer
11, operation mode
- Floor down Rounding num = Math.floor (num);
- Ceil rounding Up num = Math.ceil (num);
- Round Rounding num = Math.Round (num);
- POW Root num = Math.pow (2, 5); is 2 of the 5-time Square
JS array && string && Timer 1