JavaScript syntax specification and commissioning

JavaScript syntax specification and commissioning


 JavaScript development environment

  A JavaScript script can use any plain text editor program development.

Common front-end development Editor:

    - Lightweight: nodepad ++, editplus, vi / vim

    - Middleweight: Sublime Text, Atom

    - Heavyweight: AptanaStudio (based on eclipse), JetBrains WebStorm (free software)

 

  IDE: Integrated Development Environment, the editor (code hints / Code Completion) + debugger + Project Management + FileWatcher (File Monitor) + Service Manager

 

  All programs run requires a corresponding environment, JavaScript running in the JS script interpreter, referred to as JS engine.

JS engine can be installed in the operating system, you may be embedded in a separate browser kernel.

Browser kernel consists of two parts:

    - Content layout engine - parse HTML / CSS

    - script interpreter engine - parsing JavaScript

 

  Currently, all the browser kernel, JS engines are installed by default.

  So, as long as the browser can interpret JS run the program.

 

  

Browser kernel

  

JavaScript syntax specification

JavaScript Notes specification

  Not interpreted code executes JavaScript engine.

  - Single-line comments: //

  - Multi-line comments: / * * /

<script>
    // 单行注释
    // document.write("hello");
    
    // 多行注释
    /*
    document.write("JavaScript");
    */
</script>

 

requirements

  - JavaScript using the ";" semicolon indicates the end of a statement.

  - strict case-sensitive.

  - string must be wrapped in quotes, single quotes, double quotes can be, but must appear in pairs.

 JavaScript script error

  JS script when an error occurs, the program will stop running, and will output an error message on the console.

  If there are a plurality of page <script> tag, JS script during execution, if a <script> tag statement is an error in a row, the tag of the error code in the same statement <script> terminates execution.

  Other code within the <script> still continue down the implementation.

 

Use Console to view a script error message

  Console (console) is a JS code debugging platform browser used.

 

  Open

    - Click the "Developer Tools" Open.

    - Use the shortcut keys F12 to open on Windows.

    - Use the shortcut command on mac + alt + i to open.

 

E.g

  

 JavaScript output

Three JavaScript output

  - Output to a page: document.write ();

  - pop-up boxes: alert ();

  - the console output: console.log ();

 JavaScript Output - Output to a page

 JavaScript uses  document.write ()  method outputs the contents of the web page.

  - Note: This method will change the structure of the original page, so rarely used in the development process.

<script>
    document.write("hello<br/>");
</script>

  

JavaScript output - pop-up boxes

 Use  alert ()  method, you can pop up a message box on the page.

  - Note: alert () method execution prompt pop-up box will pause the program and can not operate the web, knowing click "OK" button, the browser does not allow custom message box is developed, there are some pages prompt box cool side that's not the browser that comes with, but with div css js I have written.

<script>
    alert("这是一个弹框提示!")
</script>

   

 JavaScript output - output to the console

 Using  the console.log ()  method may output the content to the console.

  - Note: console.log () This method is commonly used debugging method is usually used to view the results of the implementation of the program.

<script>
    console.log("这是向控制台输出的结果")
</script>

  

JavaScript composition

 Full JavaScript language consists of three parts

  - ECMAScript (Core JavaScript) - describes the basic syntax of the language and subject to change.

  - DOM (Document Object Model, Document Object Model) - describes a method for processing content and page elements and interfaces.

  - BOM(浏览器对象模型,Browser Object Model)——描述了访问和操作浏览器窗口的方法和接口。

 

发布了118 篇原创文章 · 获赞 123 · 访问量 6万+

Guess you like

Origin blog.csdn.net/weixin_42776111/article/details/104574243
Recommended