Javascript Introduction
There are three front-end web:
-
HTML: from the semantic point of view, describe the structure of the page
-
CSS: From an aesthetic point of view, describing the style (beautification page)
-
JavaScript: From the point of view, describe the behavior of the interaction (enhanced user experience)
JavaScript composition
-
ECMAScript 5.0: js the standard defines the syntax: contains variables, expressions, operators, functions, IF statement for loop while loop, built-in functions
-
DOM: API operations on page elements. For example, let the box Show hidden, color, form validation animated form
-
BOM: API operate some functions of the browser. For example, refresh the page forward and back, let the browser automatically scroll as
Tool selection:
Common front-end development tools: sublime, visual Studio Code, HBuilder, Webstorm.
So PCharm with WebStorm you are using JetBrains Introduces editing tools, the development phase is recommended.
JS & reference variable naming:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-U-Compatible" content="IE-edge"> <meta name="viewport" content="width=device-width,initial-scale=1"> <title>01 Js简介&引入</title> </head> <body> <!- Script<->inscribed type of the type = "text / JavaScript" > // you write js code (two slashes // is a comment) console.log ( ' the Hello World! ' ); // console output Alert ( ' the Hello World! ' ) ; // browser box comes with warning shots </ Script > <! - external -> <! - written into the src js file specified, similar to the python module in the introduction, the file specified the js are called here -> < Script of the type = "text / JavaScript" src = "jQuery-3.3.1.js" > </ Script > <-! variables -> <! -Define the variable: var is a keyword used to define variables. The so-called keywords, that there are special features of small words. The keyword must be separated by a space. -> <! - assignment of variables: the equal sign represents the assignment, the value of the right-hand side, assigned to the variable on the left. -> <! - variable names: we can take to any variable name. -> < Script type = "text / JavaScript" > // directly define the variable var keyword assignment + declared variables js, note terminated with a semicolon a code var STR = ' the Hello World! ' ; the console.log (STR); // assignment may define the var A; the console.log (A); // console output undefined because this time is not defined to the variable A = 10086 ; the console.log (A); //If there is no direct reference to the definition will complain console.log (the X-); // console error: Uncaught ReferenceError: the X-IS not defined </ Script > </ body > </ HTML >
Naming variables
There are naming the variable name: only by English letters, numbers, underscores, dollar sign $ constitution, and can not start with a number, JavaScript and can not be reserved words.