Overview of JavaScript
Used primarily for Web pages (i.e., runs in browser)
To make them more interactive
To get updates from the server without reloading the page (Ajax)
Use growing in contexts other than Web browsers
Node.js for running JavaScript on server
Mozilla Rhino for running JavaScript on desktop
Simpler than most other programming languages (arguably)
So a good starting point for beginning programmers
Second-most popular language behind Java (arguably)
So many jobs available
Not closely related to Java
Despite the similar-sounding names
Interactive JavaScript Practice
Firebug or Google Chrome Tools
Use Firebug command line for interactive testing
Variables
Introduce with “var”
-For global variables (!) and local variables.
-No “var” for function arguments
You do not declare types
-Some people say JavaScript is “untyped” language, but technically it is “dynamically typed” language
- JavaScript is very liberal about converting types
There are only two scopes
-Global scope
-Be very careful with this when using Ajax
-Can cause race conditions
-Function (lexical) scope
-There is not block scope as in Java
Operators
和JAVA一样
Functions: Basics
JavaScript: Functions
Functional programming, not object-oriented programming
OOP in JavaScript is radically different than in most languages