1. Introduction to JavaScript * is an object-based and event-driven language for applications and clients. -Object-based: * * Provides a lot of objects, can be directly used to use-event-driven: * * HTML to do site static effect, JavaScript dynamic effect-client: specifically refers to the is the browser * JS features (1) interactivity-Dynamic interaction of information (2) security-JS cannot access local disk files (3) cross-platform-ja VA inside the cross-platform, virtual machine-only can support JS browser, can run * JavaScript and Java difference (Lei Feng and Leifeng Pagoda) (1) Java is Sun, now Oracle;js is the Netscape company (2) JavaScript is Object-based, Java is Object-oriented (3) Java is a strong type of language, JS is a weak type of language-such as the java inside int i = "10"; -Js:var i = 10; var m = "10"; (4) JavaScript can be executed only by parsing, and Java needs to be compiled into a bytecode file before execution. * The composition of JavaScript (below JS) consists of three parts (1) ECMASCRIPT-ECMA: European Computer Association-has the ECMA organization developed the syntax of JS, statement ..... (2) Bom-broswer object model: Browser object models (3) Dom-document object Model: Document Object Models 2, JS, and HTML nodes <script (two kinds) First:-Use a label type= "Text/javascript" > JS code; </script> Second:-Use the script tag to introduce an external JSFILE * * * Create a JS file, write JS code-<script type= "Text/javascript" src= "1.js" ></script> * * Use the second party , do not write the JS code in the script tag, will not be executed. 3. JS primitive type and declaration variable * * Java basic data type byte short int long float double char Boolean * define variable use keyword var * * js Primitive type (five) -String: String * * * var str = "ABC"; -Number: Numeric Type * * * var m = 123; -Boolean:true and False * * * var flag = true; -NULL * * * var date = new Date (); Gets a reference to the object, null indicates that the object reference is empty, and the reference to all objects is also object-undifined * * * defines a variable, no assignment * * var Cay * * typeof (); View the data type of the current variable 4, JS statement-the statement in Java: * * if judgment * * SWITCH statement * * Loop for while do-while-js these statements inside * * If judgment statement * * =: indicates assignment = = =: Indicates judgment * * SWITCH statement-does Java support data type string support? In jdk1.7 start support-JS inside Support-switch (a) {case 5:break; Case 6:break; Default: ...} * * Loop statement for while Do-while-while loop * * * * var i = 5; while (i>1) {alert (i); i--; }-For Loop * * * * (int i=0;i<=10;i++) {} for (Var mm=0;mm<=3;mm++) { alert (mm); } * * i++ ++i and Java inside the same 5, JS operator * * + =: x+=y; ===> X=x+y; * * JS inside does not distinguish between integer and decimal var j = 123; alert (j/1000*1000); j/1000*1000 in Java to get the result is 0//in JS does not distinguish between integers and decimals, 123/1000=0.123 * 1000 = 123 * * String addition and subtraction operation var str = "123"; * * If add time, do is string connection * * If subtract, do is subtract operation *//string action var str = "456"; alert (str+1); The result of operation in Java is 4561, inside JS or 4561 alert (str-1); Subtract, perform subtraction operation * Hint Nan: Indicates not a number * * Boolean type can also operate * * * If set to true, equivalent to this value is 1 * * * If set to False, the equivalent of this value is 0 ** == and = = = Difference * * To make a judgment * = = comparison is only the value * = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = document.write ("AAA"); Document.wirte ("
Javaweb's JavaScript combination