javascript: Browser Object-based event-driven scripting language consists of: Javascript:ecmascript (ES) DOM Document Object model BOM Browser object model, three components
Three ways to use JS 1. HTML tags embedded Js:<button ondblclick= "Javascript:alert (' SSAS ')" > Point me!!! </button> not recommended for use 2. Use directly in HTML pages: <script type= "Text/javascript" >//JS code </script>3. Referencing external JS file:< Script language= "JavaScript" src= "></script> [Considerations" ①. js code in the page and reference JS code can be embedded in any location of the page, but the location is different, will affect the execution sequence of JS code; for example <script></script> In front of the body, the JS code ② is executed before the page is loaded. The JS code in the page uses the type attribute to refer to the external JS file using the language. ③. The script tag that references the external JS file must appear in pairs and cannot have any code assignment inside the tag: use VAR to declare the variable to be valid only at the current function scope without using VAR, directly assign the value of the generated variable, default to the global variable, the entire JS file valid var a , b,c=1; the same declaration statement, declaring multiple variables at the same time, separating the variables with commas. Naming conventions for variables: ① variable names can only have alphanumeric _$ composition ② cannot be a numeric ③ variable is case-sensitive, uppercase and lowercase are variable data types in different variables js: Undefined, variable declared with VAR, no initialization assignment var Anull: Represents an empty reference. var a = Nullboolean: True or FALSE, optional value true/falsenumber: A numeric type, which can be a decimal or an integer string: a String type. The contents of a "or" package are called strings. An output statement in object (complex data type) &NBSP;JS: An output statement that prints the contents of the write () to the browser screen; Note: Anything other than variables/constants must be placed in "" when printing. Variables/constants must be placed outside the "" "when the contents of the print are multi-part, with + connection pop-up window output: Alart () pop-up window input: Promp () operator priority ()! + +--%/*+ < >= <===!=&&| | various assignments = + = *=/=%= Branching structure: the expression in the If-else structure if (), the result of the operation should be: ①boolean:true true false ② string: The non-empty string is a vacuum string false ③number:0 false not 0 are true ④null/nan/ Undefined: All is False ⑤object type: All is true multiple if, ladder if multiple if structure, each judgment condition is mutually exclusive! Only one route nested if structure can be multiple nesting, but in principle no more than 3 layers switch-case structure Note: The expression in ①switch () and the expression following each case can be any data type supported by JS ( objects and arrays do not); All constant expressions after ②case must be different, otherwise only the first will be executed; The constants after ③case can be any data type (objects and arrays not); different case of the same switch structure can be many different data types ④ Switch in the judgment of the time, the use of the same equality to judge the role of ⑤break: After executing the case code, out of the current switch structure, if the consequences of a lack of break: start with the right cases, execute all cases and Default⑥ When the switch structure is judged, the subsequent items are no longer judged when the correct case item is encountered. The execution rate of the ⑦switch structure in turn is faster than the multiple if structure. The switch structure looping structure is a priority in the case of multiple branching: For loop for loops there are three expressions: ① defines the loop variable ② determines the loop condition ③ update the loop variable between three expressions, separated by 1. For loop three expressions can be omitted, but two, integral 2.for loop characteristics: First judge, then execute 3.for loop three expressions, can have a multi-part composition, between, separated. But the second part of the judgment condition needs to use && connection, the final result is true/False while cycle first judgment, then executes the do-while cycle first executes, then the judgment; even if the initial conditions are not established, Do-while will cycle at least 1 times
Considerations for JavaScript language learning