JavaScript learning is the last one ... JS Foundation has been the core of the part of a thorough study ...
The only drawback is that they are not particularly skilled in their use ... Today is the last chapter of JS content. Also JS
The most common content in ...
Learning content:
JS external classes and the use of internal classes
JS external classes and internal classes, the external class is our own definition of the class, in fact, it is important or JS provide the internal class, just like the API provided in Java, JS also provides some common APIs
Inner classes are divided into static classes and dynamic classes
Static classes are the methods and variables that we can call directly without creating an object.
1.Math objects
<script language= "javascript" type= "Text/javascript" >//Common ValuesMath.e//index E..Math.PI//Pi //Common MethodsMath.Abs (-12)//12 take absolute valueMATH.SQRT (4);//2 Open RadicalMath.ln2//Natural logarithm of 2Math.ln10//Natural logarithm of 10math.log2e//the natural logarithm of the base of the twomath.log10e//natural logarithm at base of 10document.write (Math.Round (4.7));//Roundingdocument.write (Math.random ())//take a random number of 0-1document.write (Math.floor (Math.random () *11));//random number between output 0-10document.write (Math.max (2,3));//2document.write (math.min);//3</script>
2.Date class
<script language= "javascript" type= "Text/javascript" > var date=New date (); Window.alert (date); Window.alert (Date.tolocalestring ()); // Show the time in the way we used to Window.alert (Date.getyear () + "" +Date.getmonth ()); Window.alert (Date.getminutes ()); </script>
3.String class
<script language= "javascript" type= "Text/javascript" >varstr1= "12345AA"; Window.alert (str.length); varArr1=str1.split ("");//string splitting function varArr2=str1.split ("");//a single point varStr= "Abc|def|oop"; varArr=str.split ("|");//Split string with | as standardWindow.alert (arr); varstr3= "ABCdef"; Window.alert (Str3.substr (1, 3));//BCD string intercept functionWindow.alert (str3.substring (1,3));//BCWindow.alert (Str3.charat (5));//F take the fifth characterWindow.alert (Str.indexof (ABC));//0 String matching function :</script>
4.Array class
<script language= "javascript" type= "Text/javascript" > var myarr=New Array (); Myarr.push ("abc"); // arr[0]= "abc" Myarr.pop (); // Delete document.write (Myarr.length ()); </script>
Arrays are similar to the stacks we learn in Java, satisfying the LIFO principle, supporting Push,pop, and so on .....
There are also the Boolean class and number, these two classes are basically used in the front, relatively simple ...
Two. Dynamic classes
Dynamic classes are relatively simple, not to elaborate, in the future we often need to define the required classes.
<script language= "javascript" type= "Text/javascript" > function A () { This . text= "AA"; } function B (s) { this. obj=new A (); this. s=new A (); } var b=new B ("ss"); alert (b.obj.text); // alert (b.ss.text); </script>
The final chapter in JavaScript Learning notes