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