JavaScript Advanced Programming 第1-3 Chapter

Source: Internet
Author: User
Tags bitwise operators

Introduction to JavaScript in the first chapter

1. JavaScript implementation: consists of three different parts: core (ECMAScript), Document Object Model (DOM), Document Object Model ( BOM)

2, ECMAScript

1) ECMAScript defined by ECMA-262 does not have a dependency onthe Web Browser, theweb the browser is just One of the possible hosting environments implemented by ECMAScript.

2) provides several components of the language: syntax, type, statement, keyword, reserved word, operator, object.

3) ECMAScript compatible: Supports All "types, values, objects, attributes, functions, and program syntax and Semantics" described by ECMA-262; supports Unicode character Standard Added "More types, values, objects, properties, and functions" not described by ECMA-262; supports "program and Regular expression syntax" ECMA-262 not defined.

3, Document Object Model (dom Span style= "FONT-FAMILY:CALIBRI;" >xml html api dom Map the entire page to a multi-tiered node structure.

4, Browser object model (bom ): Working with browser windows and frames, And some other extended functions. The function of the new browser window, the ability to move, zoom and close the browser window, and the navigator location screen object; For the user display resolution details. cookie support; like xmlhttprequest and ie Span style= "font-family: the song Body;" The activexobject And so on custom objects.

Chapter II using JavaScript in HTML

1 . Attributes of the <script> element

1) Async: optional, means to download the script immediately, but can do the other page operation,async="Async", only applicable to external files,Firefox3.6, Safari5 and Chrome are available

2) CharSet: Optional, indicating the character set of the code specified by the src attribute

3) Defer: optional, indicating that the script can be deferred until the document is fully parsed and displayed before execution,defer="Defer", applies only to external files,IE4, Firefox3.5,Safari5 and Chrome are available

4) Language: Obsolete

5) src: optional, representing the external file containing the code to be executed

6) Type(MIME type): Optional, which represents the content type for writing code using the scripting language, typically type=text/javascript

2. Use of<script> elements: JavaScript contained within the <script> element The code will be interpreted from top to bottom, in the interpreter <script> until all code inside the element is evaluated, the rest of the page is not loaded or displayed by the browser. Be careful not to place </script> in a non-end position , or use the escape character "\".

1) Embed JavaScript codedirectly in the page:<script type="Text/javascript" ></script>

2) contains external JavaScript files:<script type="Text/javascript" src= "Example.js" ></script >, be careful not to include the embed code again.

3 . Position of <script> element

1) included in the element

2) included at the end of the <body> element

4. Document mode

1) Promiscuous mode: will make IE behave the same as IE5

2) Standard mode: will make IE 's behavior closer to standard behavior

<!--HTML 4.01 Strict--

<! DOCTYPE HTML PUBLIC "-/w3c//dtd HTML 4.01 transitional//en" "HTTP://WWW.W3.ORG/TR/HTML4/STRICT.DTD" >

<!--XHTML 1.0 Strict--

<! DOCTYPE HTML Public "-/W3C//DTD XHTML 1.0 strictl//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtm1-strict.dtd" >

<!--HTML5--

<! DOCTYPE html>

5, <noscript> elements:<noscript> can contain any that can appear in the <body> HTML element, <script> except for the element. The browser does not support scripting or browser support scripts but displays the contents of <noscript> when the script is disabled .

Chapter III Basic Concepts

1. Grammar

1) Case-sensitive

2) Identifier: The first character must be a letter, underscore, and dollar sign, and other characters can be letters, underscores, dollar signs, or numbers. ECMAScript The identifier is in hump case format, that is, the first letter is lowercase, and the first letter of each of the remaining words is capitalized

3) Note: single-line comment //, multiline comment /**/

4) Strict mode: You can add "use strict"at the top of the page and the function body,ie10+,firefox4+, safari5.1+,opera12+ and Chrome are available

5) Statement: The statement in ECMAScript ends with a semicolon, and a block of code is used in the control statement.

2. Keywords and reserved words

1) Keywords: Break, Do,instanceof,typeof, Case,Else,New,var,Catch,finally,return,void,Continue, for,Switch, while,Debugger,function, This, with,default,if,Throw,Delete,inch,Try

2) Reserved words:Abstract,enum,int, Short,Boolean,Export,Interface,Static,byte,extends,Long,Super,Char,Final,native,synchronized,class,float, Package,throws,Const,Goto,Private,transient,Debugger,Implements,protected,volatile,Double,Import, Public, Let,yield

3) Others:eval,arguments

3, variables: the variables are defined using the var operator, the variable defined by the var operator becomes a local variable in the scope that defines the variable; omitting var The variable created by the operator is a global variable; you can use a statement to define multiple variables, separated by commas

4. Data type: Basic data type:Undefined,Null,Boolean,number and String; complex data type:Object

1) typeof operator

2) Undefined type: Used to distinguish between null object pointers and uninitialized variables

3) NULL type: value is null

4) Boolean Type: value is true or false

Numeric type

the value converted to true

value converted to false

Boolean

True

False

String

Any non-empty string

""(empty string)

Number

Any non-0 numeric value (including infinity)

0 and NaN

Object

Any object

Null

underfined

N/A

Undefined

5) Number type: decimal, octal (first bit must be 0, followed by 0~7), Hex (first bit must be 0x, followed by 0~f)

6) String type

7) type of Object

5. Operator

1) Unary operators: increment and decrement operators, unary plus and minus operators for pre-and post-position

2) Bitwise operators: Bitwise non (not), bitwise and (and), bitwise OR (OR), bitwise XOR (XOR), left shift, signed right shift, unsigned right shift

3) Boolean operator: logical non, logical and logical, or

4) Multiplicative operators: multiplication, division, modulus of evaluation

5) Additive Operator: addition, subtraction

6) relational operator: less than, greater than, less than or equal to, greater than or equal to

7) Equality operators: equality and inequality, congruent and non-congruent

8) Assignment Operator: Multiply Assignment (*=), except Assignment (/=), modulo assignment (%=), add Assignment (+ =), minus assignment (-=), Left Shift Assignment (<<=), Signed right Shift Assignment (>>=), unsigned Right Shift assignment (>>>=)

9) comma operator

6. Statements

1) If statement

2) Do-while statement

3) While statement

4) for statement

5) For-in statement: Property used to enumerate objects

6) lable statement: Add tags to your code

7) Break and continue statements

8) with statement: Set the scope of the code to a specific object

9) Switch statement

7. Functions

1) Parameters

2) No Overloads

JavaScript Advanced Programming 第1-3

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.