One. JavaScript is a scripting language, characterized by: explanatory, Object-based, event-driven, security and cross-platform features
For these features it is necessary to explain
Explanatory: Javascripte itself is an explanatory language
Object-based: that is, it can create objects
Event-driven: The simple point is: OnClick () It can achieve the mouse click on the event that occurs
Security: It does not allow access to the local disk, cannot write data to the server, and does not allow the network documents to be modified, deleted, only through the browser to achieve dynamic interaction of information, so as to effectively prevent data loss
Cross-platform: JavaScript is dependent on the browser itself and is not related to the operating system
Two. Language Basics:
(1). Grammatical features
1.JavaScript is case-sensitive
2. The end of each line of good points, (preferably plus, to ensure the accuracy of the code;
3. Variable is a weak type of language
4. Use curly braces to mark code blocks {}
5. Comment: Line comment://Multiline Comment:/* */
(2) Keywords: almost as basic as Java
(3) Data type
Six Big Data types: Numeric, character, Boolean, translatable, null (NULL), undefined
Where Nan is a special numeric constant, that is, a non-numeric
(4) Definition and use of variables
1. Naming rules for variables similar to Java
2. Disclaimer
3. Scope:
A. var and no var are global variables for external functions
B. In the function with VAR declaration is local, in the function without VAR declared variable is global
C. The variables defined in the parameters of the function are local, and the parameters of the function cannot be defined with Var.
(5) The use of operators: roughly also similar to Java, but it is worth noting that
i++ [Add 1 after using I]
++i [Make I minus one before using I]
Eg: (the value of i=1;j=i++//j is 1,i value is 2) i=1;j=++i; The value of J is 2,i value is 2)
(6) Process Control block statement: That is, If/else switch/case this statement is similar to Java syntax
Three functions
function's keyword: functions
eg function functionname (parameter1,parameter2,...) {
Statement
(return experssion;)
}
The invocation of the 1 function is usually used in conjunction with the time-bound
Some of the commonly used events are: onclick; onblur,onchange
eg <input type= "button" onclick= "Check ()"
Four common objects
Some common objects of window: Open, close
Window also has some methods, for example: Alert (), setinterval () These are omitted window
(1) window.open (url,windowname[,location]);
URL: Address
Windowname: Specifies the name of the window, if it exists, there is no need to recreate
Location: Set the properties of the window (Width,length ... )
(2) Window.close ()
Used to close the current window
Five String and Date
1 Many methods of string types in Java are also common eg:split () in JavaScript. IndexOf ()
2 Date is dynamic and must be created
eg
<script language= "javascript" > function realsystime (clock) { var now=new Date (); var year=now.getfullyear (); Gets the year, the method that gets the property is get start var month=now.getmonth () +1; Gets the month because the month is from 0 to one var day=now.getday (); var hour=now.gethours (); var min=now.getminutes () var sec=mow.getseconds (); var arr_week=new Array ("Sunday", Monday ", Tuesday", Wednesday ", Thursday", Friday ", Saturday",); var week=arr_week[day]; } </script>
The first summary of JavaScript