Common internal classes for JavaScript

Source: Internet
Author: User

<!doctype html>
<meta charset= "Utf-8" >
<title> Untitled Document </title>
<script type= "Text/javascript" >
//javascript Inner class, number class
var num=new number (12.3456);
document.write (num.tofixed (2));
document.write ("<br>" +number.min_value);
//javascript Inner class, math class
var ma=90.1;
Rounding down
document.write ("<br>" +math.floor (49.5));
Rounding up
document.write ("<br>" +math.ceil (13.2));
document.write ("<br>" +math.random (Math.random () *100));
//javascript inner class, date class
var mydate=new Date ();
document.write ("<br>" +mydate.tolocalestring ());
document.write ("<br>" + (Mydate.getmonth () +1));
//javascript inner 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 inner class, array class
arr[0]=12;
arr[1]= "Hello";
Arr[2]= "China";
Delete 2nd Element--Subscript 1
The first 1 indicates the deletion of the element, and the second 1 means the deletion of a
Arr.splice (a);
Modify the second "Hello", "World"
Update
Arr.splice ("World");
Put a new data "Beijing", added to the 1th element behind
Arr.splice (1, 0, "Beijing");
for (var key in arr) {
document.write (arr[key]+ "<br>");
}
</script>
<body>
</body>

These kinds of classes are very important, it is necessary to read the manual, it is written here are common usage.

Copyright Notice: Bo Master original articles, reproduced please indicate the source. Http://blog.csdn.net/dzy21

Common internal classes for JavaScript

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.