JavaScript study concluded [1] first met JS

1. What is JavaScript?

  JavaScript is a cross-platform, object-oriented dynamic, weakly typed lightweight interpreted language, is an object-based and event-driven and has the relative safety of client-side scripting language. HTML documents can be applied to provide dynamic interactivity on the site, he is different from Java. It simply is a browser-based HTML document processing, achieve a variety of web effects, in response to various user operations, and add dynamic effects for web pages to enhance user experiences, such as pictures scrolling effect, click the login button pop-up dialog box, the mouse moved out animation, form submission data validation.

2, why should learn JavaScript?

  JavaScript is commonly known as JS, the purpose of his invention, that is, as a built-in scripting language browser provides the ability to manipulate the browser for Web developers, who can make the page showing a variety of special effects, to provide users with a friendly and interactive experience . With the advent of Ajax technology, front-end and back-end can exchange data without refreshing the page, and update the prevalence of page data, jQuery and other JS library to make writing easier than ever, Bootstrap front-end framework infinite reduce the cost of leaving, greatly improving the efficiency of front-end development, JS prospects in the front end of the field is very broad.

  With the release of Node, so JS can not only run in the front, it can also run on the server. This is JS is a qualitative breakthrough, Node.js project so that JS can be used for large-scale projects to develop server-side, front and rear ends of the site have been developed by JS called reality.

  JS addition to this can be resolved browser can also be used as back-end language, a growing number of applications, the JS as embedded scripting language that can be used to build mobile terminal APP, HTML game development, you can not rely on browser, to build desktop applications.

  It is expected that the final JS using only one language, you can develop a program for different platforms (including desktop, server, handheld terminal) of. In Jeef Atwood published blog, he proposed the famous "Atwood's Law" that "can be used in any application implemented in JavaScript, with JavaScript will eventually achieve."

  Compared to learn other languages, JS easy to learn. As long as the browser, you can run the JS program, as long as the text editor, you can write JS code. Without having to install complex IED (Integrated Development Environment) and compiler. JS relatively simple grammar, syntax itself is not particularly large, but flexible language, can use only simple commands to complete most of the operation.

  Although JS core grammar is not difficult to learn, but to really learn through is not an easy task, JS is actually very complex, with the study, the more powerful he can understand. JS to play a role, must be used with other components, these external components varied, but a huge number, related to all aspects of network applications, such as editor components, components of interest and other QQ space provided, to master them is not easy, we must make relentless effort. JS language has some design flaws, there will be strange to run the results in some places, the mainstream browser support for JS different, compatibility is the most irritating thing, learning JS, a large part of the time are used to engage in what areas there are clear pitfalls.

  Nevertheless, JS position is unshakable, published in 2015, ranking the world's language, JS ranked seventh, compared with last year, there has been improvement. Ecma speed up (by Ecma-262 standard-scripting language) a standardized language, making the JS function growing, and grammar flaws and quirks also got to make up for that, as of the latest version this year JS as ECMAScript 2015, also known as ES6, increase many new features. So, JS is still worth learning, not only to master, but also to learn fine, especially for the Web front-end development engineers particularly important.

3, JavaScript composition

  JS composed of three parts:

  ECMAScript: also known as interpreter, act as translators role, which is the core of the JS.

  DOM: Document Object Model (Document Object Model). JS DOM gives the ability to manipulate HTML, that document operation.

  BOM: browser object model (Browser Object Model). JS BOM gives the ability to operate the browser, that window operation.

4, JavaScript usage

  HTML scripts must be located in the <script> </ script> tag between. You can put an unlimited number of scripts in an HTML document. HTML scripts may be located in the <head> or the <body>, or both are present in both parts. The usual practice is to function in the <head>, or on the bottom of the page, so as not to interfere with the contents of the page.

  The script can also be stored in an external file, the file extension .js, external files usually contain code that is used by multiple pages. NOTE: When using an external script, the script does not contain <script> tags.

5, the process of writing JavaScript

  First, and most important, it has to implement the principles of web pages to find out the effect of, to what purpose, you need to make changes, and what actions the user which attributes some action by the user, step by step to achieve the idea of ​​JS method.

  Then HTML + CSS page layout.

  Then select the name of the property to be modified (id or class).

  Then the user's operation, select the appropriate trigger event.

  Finally, in the event, according to the concept of the first step, write JS code.

Guess you like

Origin www.cnblogs.com/jlfw/p/12575892.html