JavaScript Small Notes

Source: Internet
Author: User

1.315360000000 ms = 10

2.Javascript take time Cut:

JavaScript gets the current timestamp: The first method: var timestamp = date.parse (new date ()); results: 1280977330000 the second method: var timestamp = (new date ()). ValueOf (); results: 1280977330748 The third method: Var timestamp=new Date (). GetTime (); results: 1280977330748 The first: The time stamp obtained is the change of milliseconds to 000 display, The second and third is to get the timestamp of the current millisecond.

The new date in 3.Javascript represents the current time!!! Equivalent to C # DateTime.Now

var mydate = new Date ();

4. C # notation for Math.random () in javascript:

equivalent of Math.random () in Javascript//get A-bit double value x, 0 < x < 1, eg:0.68637410117610087public do Uble mathrandom () {Random RDM = new Random ();d ouble betweenzerotoone17bit = RDM. Nextdouble (); return betweenzerotoone17bit;}

5.

Number.tostring (): Converts a number to a string. The cardinality or base specified with its parameters (the baseline range is 2-36). If the argument is omitted, the cardinality 10 is used. When the parameter value is 2 o'clock, a binary number is returned.
Example code four:
Result: Displayed in the browser:
34
100010
42
22

<script type= "Text/javascript" >    var a =;    document.write (a.tostring () + "<br/>");    document.write (a.tostring (2) + "<br/>");    document.write (a.tostring (8) + "<br/>");    document.write (a.tostring (+) + "<br/>"); </script>

  

JavaScript Small Notes

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.