javascript zero-based entry (white)

1 . JS historical
JavaScript as part of the Netscape Navigator browser first appeared in 1996. Its initial design
meter goal is to improve web user experience.
Author: Brendan Eich
Beginning JavaScript is named LiveScript, after due and Sun cooperation, due to marketing needs renamed
JavaScript. Later, Sun's acquisition by Oracle, JavaScript belongs to all of Oracle.

2 . Browser composition
1.shell part - user operable portion of the housing
2. The core part - part invisible to the user
1) a rendering engine (rendering and grammar rules)
2) JS engine
other modules 3) (e.g., asynchronous)

3 . Js engine
released in 2001 ie6, for the first time js engine optimization. In 2008 Google released the latest browser Chrome, which is the use of optimized javascript engine, engine, code-named V8, because js code can be directly converted into machine code to execute, and then to fast and famous. After Firefox has launched a js engine with powerful features Firefox3.5 TraceMonkey (for frequently executed code path optimization done)
Firefox 4.0 JeagerMonkey

4 . To start learning js
three parts js ECMAScript, DOM, BOM
how to introduce js?
1, page embedded labels, write head which is also OK, write the body inside is also OK
cases:

<body>
<script type="text/javascript"> 
//告诉浏览器我们是 js
</script>
</body>

2, external js file, introduced
for example: lesson.js to save the file, and then introduced into the html
for the web standards (standard w3c a) the structure (html), row (js), style (CSS)
phase separation usually external introduction.
A file may include multiple css, js-- not mix
special write pages, most of the writing on the outside - not mix
If both wrote and external js js internal, external js file is then displayed

js grid of force (unique features)

Compiled language An interpreted language
How to do it Throughout the post-translational generate the translated documents, program execution files translated See line translation line, does not generate a specific file
Representatives language C,C++ JS, PHP, python, horn No.
advantage Faster (commonly used in the system, game) Cross-platform
Shortcoming Transplantation is not good (not cross-platform, window and Linux can not be mixed) A little slower

js is an interpreted language :( do not need to be compiled into a file) Cross-platform
java first by javac, compiled into .class files, interpreted by jvm (Java Virtual Machine)
.java javac → → → .class → jvm → compiled interpreted (java cross-platform) (java is oak language)

Is a single-threaded asynchronous loading: at the same time can only do one thing --js engine is a single-threaded (at the same time do a lot of things called multi-threading) ECMA (European Computer Manufacturers Association) mark: In order to achieve technological advantages, Microsoft launched JScript , CEnvi launched ScriptEase, the same can be run with JavaScript in your browser. In order to unify the specifications JavaScript is compatible with ECMA standard, also known as ECMAScript. rotation time slice is js

Here Insert Picture Description

Major browsers (there must be a separate kernel) market share of more than 3% Core Name
IE trident
chrome webkit/blink
firefox gecko
opera presto
safari webkit

Js start learning

three parts js ECMAScript, DOM, BOM
how to introduce JS?
1, page embedded labels, write head which is also OK, write the body inside is also OK
Cases

<body>
<script type="text/javascript"> 
//告诉浏览器我们是 js
</script>
</body>

2, external js file, introduced
for example: lesson.js to save the file, and then introduced into the html
for the web standards (standard w3c a) the structure (html), behavior (js), style (CSS)
phase separation usually external introduction.
A file may include multiple css, js-- not mix
special write pages, most of the writing on the outside - not mix
If both wrote and external js js internal, external js file is then displayed

js basic syntax of
a variable (variable)
the HTML, CSS is not a programming language, the language is a computer programming language variables and functions needed
variables are storing things, to facilitate subsequent use of the block
1) variable declarations
1. declarations, assignments decomposition
var a; this is called variable declarations. We apply the system in the var this box, assign a name to a 100 call, writing a = 100, this is not the equal sign is the assignment
var a; a = 100; can be simplified written as a = 100 var;
2. single var statement method

Here Insert Picture Description

As written as: var a = 10; a = 20; 20 will then cover off the back of the front 10
2) naming convention (proximity English words) ---- from the variable name must be in English semantic
1. variable names must be in English letters, beginning $
2 variable names can include letters,
, $, digital
3. the system can not use keywords, reserved words as variable names

Here Insert Picture Description

The basic syntax

Here are the variables, for example: var A = 10;
var = 20 is B;
var c;
c = A + B;
to the right hand side of the operation a + b, after the operation, and then assigned to the left c
first value, then the assignment
operation is greater than the priority assignment
js language is dynamic, the dynamic languages basically interpreted languages, scripting language interpreted languages basically
js language is a float (with decimal point)
value type (data type)
1, unchangeable the original value (the stack data) stack stack
number the, string, Boolean, undefined, null
has not changed to the value of the put, will change the room number is null (the hard principle)
number the number, a = 123 Example var;
string string, language put double quotes, Example var a = "language", "" is the empty string
Boolean Boolean numbers, on two values, to false, to true
undefined is not defined, the assignment represents not only a value underfined
null space representatives, a placeholder, is covered with a null

Example A = 10 var;
var A = B;
A = 20 is;
document.write (B);
Answer: 10
original value I is a value into another value which, to change the first value, the second value constant
2, a reference value (data stack) is substantially placed inside the heap stack
array array, Object, function ... data, RegExp regular
var arr = [1,2,3,4,5, false, "abc"]; // this is an array
Example: ARR = var [. 1];
var = ARR of arr1;
arr.push (2);
document.write (of arr1);
answer: arr is 1, 2. is 1, 2 arr1
reference value is the first value into a second value which, to change the first value, the second value is also changed
js determined by the value type. And references to the original value only difference values are different assignment form

Here Insert Picture Description
var a = 10; var b = a; is taken to a 10, b placed inside a Copy, changing the value of a, b values are not
changed, and then a = 20; 10 or when the value of b, does not change
var arr = [1,2]; var arr1 = arr; arr.push (3);
answer: to this [1,2] put 3, arr arr1 and are [1,2,3]
reference value the stack is placed inside the memory address in the stack, the address is copied, varying arr, arr1 has changed
var arr = [1,2]; var arr1 = arr; arr = [1,3]; document.write (arr1 )
the answer: arr = [1,3]; is built a new room. arr1 1, 2, and now the newly introduced value is inserted into the "room",
will re-apply for a room in the heap, and point to the new room

js statement basic rules

1, the rear end of the statement semicolons ";" but the function test () {}, for () {}, if () {} behind do not semicolon
2, js syntax error will cause the subsequent code terminates, but not js code will affect other block
error divided into two types
1) low-level errors (parsing error), can not write Chinese
2) logic errors (standard error, extenuating circumstances, the execution can not be wrong)
3, writing format must be standardized "= + / -" both sides should have spaces

Published an original article · won praise 4 · Views 196

Guess you like

Origin blog.csdn.net/XiaoYong0430/article/details/105269025