JS array && string && Timer 1

Source: Internet
Author: User
Tags array length pow

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.