Common internal javascript classes and common javascript

Source: Internet
Author: User

Common internal javascript classes and common javascript
<! Doctype html>
<Html>
<Head>
<Meta charset = "UTF-8">
<Title> untitled document </title>
</Head>
<Script type = "text/javascript">
// Javascript internal class, Number class
Var num = newnumber (12.3456 );
Document. write (num. toFixed (2 ));
Document. write ("<br>" + Number. MIN_VALUE );
// Javascript internal class, Math class
Var ma = 90.1;
// Round down
Document. write ("<br>" + Math. floor (49.5 ));
// Rounded up
Document. write ("<br>" + Math. ceil (13.2 ));
Document. write ("<br>" + Math. random (Math. random () * 100 ));
// Javascript internal class, Date class
Var mydate = new Date ();
Document. write ("<br>" + mydate. toLocaleString ());
Document. write ("<br>" + (mydate. getMonth () + 1 ));
// Javascript internal class, String class
Var txt = "h Han llo China ";
Document. write ("<br>" + txt. indexOf ("worldr "));
Var arr = txt. split ("");
Document. write (arr );
Var sub = txt. substr (3, 3 );
Var sub = txt. substring (0, 2 );
Var sub = txt. charAt (3 );
// Javascript internal class, Array class
Arr [0] = 12;
Arr [1] = "hello ";
Arr [2] = "China ";
// Delete the first element. The subscript is 1.
// The first 1 indicates the elements to be deleted, and the second 1 indicates that the first element is deleted.
Arr. splice (1, 1 );
// Modify the second "hello"-> "world"
// Update
Arr. splice (1, 1, "world ");
// Add a new data "Beijing" to the end of element 1st
Arr. splice (1, 0, "Beijing ");
For (var key in arr ){
Document. write (arr [key] + "<br> ");
}
</Script>
<Body>
</Body>

</Html>

These classes are very important. You need to read more manuals. Here we write common usage.

Copyright statement: original post of the blogger. For details, refer to the source. Http://blog.csdn.net/dzy21

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.