Home > Web Front-end > JS Tutorial > body text

JavaScript for Web Development_Basic Knowledge

WBOY
Release: 2016-05-16 17:54:52
Original
1251 people have browsed it

Xiaoyin
The author believes that web development includes designing html, javascript, css, and a high-level language, such as c#, java, etc. This article is divided into three parts. The first part is a brief introduction to javascript, and the second part is understanding ECMAscript. The last part is the basics of JavaScript, so I don’t have a deep understanding of JavaScript. I can only analyze it from the following points. If it is wrong, please point it out, thank you! The main content is:

Part One :

javascript
Features
implementation of javascript
ECMAScript standard
development of javascript

Part 2:

About ECMAScript
1. Same syntax
2. Object-oriented programming
3. Functions are also objects
4. Objects have prototypes
5. Convenient data construction
6. JavaScript Object Notation (JSON)
7. Fifth Edition

Part 3:
1. JavaScript syntax
2. Variables
3. Data Type
4. Conditional statement
5. Loop statement
6. Function
Reference

Part One:
Introduction to JavaScript
JavaScript is A scripting language based on Object and Event Driven with security features. The purpose of using it is to work with HTML hypertext markup language and Java script language (Java applet) to link multiple objects in a Web page and interact with Web clients. This allows you to develop client applications, etc. It is implemented in the standard HTML language by embedding or calling in. Its appearance makes up for the shortcomings of the HTML language, and it is a compromise between Java and HTML.
Features
is a scripting language
JavaScript is a scripting language that uses Programming is implemented in the form of small program segments. Like other scripting languages, JavaScript is also an interpreted language, which provides an easy development process. Its basic structural form is very similar to C, C++, VB, and Delphi. But it does not need to be compiled first like these languages, but is interpreted line by line during the running of the program. It is combined with HTML tags to facilitate user operations. Object-based language. JavaScript is an object-based language and can be considered an object-oriented language. This means that it can use objects it has already created. Therefore, much functionality can come from the interaction of methods of objects in a scripting environment with scripts.
Simplicity
The simplicity of JavaScript is mainly reflected in: First of all, it is a simple and compact design based on Java's basic statements and control flow, which is a very good transition for learning Java. Secondly, its variable type is weakly typed and does not use strict data types.
Security
JavaScript is a security language. It does not allow access to the local hard drive, cannot store data on the server, and does not allow modification and deletion of network documents. It can only be implemented through the browser. Information browsing or dynamic interaction. This effectively prevents data loss.
Dynamic
JavaScript is dynamic, it can respond directly to user or customer input without going through a Web service program. It responds to users in an event-driven manner. The so-called event-driven refers to the action generated by performing a certain operation on the home page, which is called an "event". For example, pressing the mouse, moving the window, selecting the menu, etc. can be regarded as events. When an event occurs, a corresponding event response may be triggered.
Cross-platform
JavaScript depends on the browser itself and has nothing to do with the operating environment. As long as the computer can run the browser and the browser supports JavaScript, it can be executed correctly. Thus realizing the dream of "write once and travel all over the world". In fact, the most outstanding thing about JavaScript is that it can do a lot of things with a small program. There is no need for a high-performance computer. The software only requires a word processing software and a browser. There is no need for a WEB server channel. Everything can be done through your own computer.
Comprehensive
JavaScript is a new description language that can be clamped into HTML files. The JavaScript language can respond to user demand events (such as form input) without using any network to transmit data back and forth. Therefore, when a user inputs a piece of data, it does not need to be passed to the server. ) processing and then passing it back can be directly processed by the client application.
JavaScript and Java are very similar, but they are not the same! Java is a much more complex programming language than JavaScript, while JavaScript is a fairly easy language to understand. JavaScript creators can be less focused on programming skills, so many Java features are not supported in Java Script.
JavaScript Implementation
Core (ECMAScript) - The core of JavaScript ECMAScript describes the syntax and basic objects of the language
Document Object Model (DOM) - DOM describes the methods and interfaces for processing web content
Browser Object Model (BOM) - BOM describes the methods and interfaces for interacting with the browser

ECMAScript standard

1997, European Computer Manufacturers Association (ECMA) formulated the ECMA-262 standard based on the JavaScript language specification, forming a specification for web scripting language.Currently, all major browsers support scripting languages ​​that comply with the ECMA-262 standard. Since then, web browsers have worked hard (albeit with varying degrees of success and failure) to use ECMAScript as the basis for JavaScript implementation. Although ECMAScript is an important standard, it is not the only part of JavaScript, and certainly not the only part that is standardized. In fact, a complete JavaScript implementation is composed of the following 3 different parts:
Core (ECMAScript) - the core of JavaScript ECMAScript describes the syntax and basic objects of the language
Document Object Model (DOM) - —DOM describes the methods and interfaces for processing web content
Browser Object Model (BOM) — BOM ​​describes the methods and interfaces for interacting with the browser
All current mainstream web browsers support ECMA-262 The third edition, JavaScript 1.5, JavaScript 1.6-1.9 is just the temporary code name for the upgrade of ECMAScript (JavaScript on Gecko) to JavaScript 2.0.
Development Trend of JavaScript

Language will always be used as a tool. This has never been changed and will never be changed in the future. Language is the way and means to use and communicate with other technologies. For example, on the Windows platform, the ADODB component can be used to enable JavaScript to process data in a database that supports SQL, and the FSO component can be used to implement local file IO functions. All this shows that JavaScript is at the top of application development and has nothing to do with the implementation of low-level technologies.
Although platform technology continues to change, JavaScript will still use the capabilities provided by the platform in an unchanged form to adapt to new needs. In the future, Web development will be a gathering place for developers, and it will also be an era when JavaScript becomes purple.

Part 2:

About ECMAScript
ECMAScript is a standard scripting language (JAVAScript) developed by ECMA (European Computer Manufacturers Association). It is currently recommended to follow ECMAScript 262 (http://www.ecma.ch/ecma1/STAND/ECMA-262.HTM), first of all, the ECMAScript specification describes the basic contents that a script programming language should implement as follows: syntax, data and variable types, statements, keys Words, reserved words, operator objects. Therefore, a script programming language that complies with the ECMA-262 specification must implement all "types, values, objects, properties, functions, and program syntax and semantics" described in the specification, and must support the Unicode Character Standard (UCS). On this basis, each specific implementation can also specify "additional types, values, objects, properties, and functions", and can define new "programs and regular expression syntaxes", etc.
1. The same syntax
First of all, the same syntax. ECMAScript is very similar to other popular open languages ​​such as c# and java, which means that other language styles seem to want to be used in it. On ECMAScript, for example,

Copy code The code is as follows:

for(i = 0; i < ; a.length; i ) {
if (a[i] == x)
return i;
}

2. Object-oriented programming
ECMAScript supports object-oriented programming. The value of a named property in an ECMAScript object. Properties and functions of objects can be called methods.
window.setTitle(user.name);
3. Functions are also objects
The function of ECMAScript is that objects and properties are passed as parameters, can be stored, and returned as results. From a functional programming perspective, let your functions and methods import functionality in a simple and flexible way from their callers.
Copy code The code is as follows:

var recent = posts.sort(function(a, b ) {
return (a.date > b.date ? -1 : 1);
}).slice(0, 10);

4. Object All have prototypes
Inspired by the programming language itself, ECMAScript objects inherit the properties of prototype objects. Prototype-based programming facilitates easy delegation and flexible override of object behavior.
Copy code The code is as follows:

function Car() { }
Car.prototype = new Object();
Car.prototype.wheels = 4;
Car.prototype.color = "black";
function RaceCar() { }
RaceCar.prototype = new Car() ;
RaceCar.prototype.color = "red";
var vroom = new RaceCar();
vroom.wheels // 4
vroom.color // "red"

5. Convenient data construction
ECMAScript talks about many common data types, which can save time and make your program more readable.
Arrays
var digits = [3, 1, 4, 1, 5, 9];
Objects

var img = { width: 320, height:160, src: "images /es.png" };
Regular expression

var email = /([^@]*)@([^@]*)/;
6. JavaScript object Notation (JSON)

JSON is a popular, lightweight data exchange format. JSON is particularly useful for interactive web pages and web services, because its syntax is a subset of ECMAScript's syntax.

7. Fifth Edition
The European Computer Manufacturers Association recently announced the final candidate draft of the fifth edition of the new ECMAScript standard. Some new features include:
1. Improved standard library
2. Standardized JSON library
3. Reflected getter and setter methods

Part 3:
1. javascript Grammar
1.1 Case sensitive
1.2 Weak type variable
var MyName="Xinzhu";var Age =22;var School="Gxnu";var male=true; 1.3 Each item can have a trailing semicolon , optional
1.4 brackets are used for code blocks

Copy code The code is as follows:

if(myName=="xinzhu"){
var age=22;
alert(age);
}

1.5javascript annotation method and c language, Same as java
2. Variables

are declared through the var keyword, such as: var boy="xinzhu"; note here that the first character is a letter, which can be uppercase or lowercase, underscore and $, and the rest It can be an underscore, $, the mother of anything; variable names cannot be keywords or reserved words

3. Data type
underfined, which represents all unknown things, underfined can be assigned to any variable or attribute, but it does not mean clearing the variable. Instead, it will add an attribute
null. There is probably this concept, but there is nothing.
boolean, yes and no, used for code processing and control of code flow
Number, linear things, with clear case and order, used for batch processing of code, can control code iteration or loop
String, rational things for people, information that can be communicated through human-machine, code can understand people Intention

4. Conditional statements

Comparison operators, logical operators, if statements, switch statements, these are all very simple and not arranged
5. Loop statements

for, while, too simple to list
6. Function
Javascript code only has one form: function, function is the type of function, the method used to complete an event
Format:
Copy code The code is as follows:

function functionName([arg0,arg1,arg2...argN ]){
statements
[returm[expression]]
}

Example:
Copy code The code is as follows:

function sayHello(sName){
alert("Hello" sName);
}
sayName(xinzhu);// Call

Reference

1. March 2012 Programming Language Ranking: The Return of JavaScript Language (1)
2. IT Company Interview Manual
3. Standard ECMA-262: http://www.ecma-international.org/publications/standards/Ecma-262-arch.htm
4. ecmascript: http://www.ecmascript.org/index.php
5. 《Mastering JavaScript.jQuery》

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template