Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
executable file 75 lines (72 sloc) 3.11 KB
-------------------------------------------------------------------------------------------
javascript is case sensitive.
Normally a block is used to group statements together in a function or in a condition
-------------------------------------------------------------------------------------------
javascript comments
single line comments start with //.
multi line comments start with /* end with */.
-------------------------------------------------------------------------------------------
Variable names must begin with a letter or the underscore character
-------------------------------------------------------------------------------------------
You declare JavaScript variables with the var keyword:
var x;
var carname;
-------------------------------------------------------------------------------------------
Variables declared outside a function become GLOBAL ,
Global variables are destroyed when you close the page.
If you declare a variable, without using "var", the variable always becomes GLOBAL.
-------------------------------------------------------------------------------------------
javascript arithmetic operator: +,-,*,/,%,++,--
javascript assignment operator: =,+=,-=,*=,/=,%=
=== is exactly equal to (value and type)
-------------------------------------------------------------------------------------------
variablename=(condition)?value1:value2
Example:
greeting=(visitor=="PRES")?"Dear President ":"Dear ";
-------------------------------------------------------------------------------------------
can use + on string:
var str = "str1 " + "str2" //"str1 str2"
var str = 1 + "1" //"11"
The rule is: If you add a number and a string, the result will be a string.
-------------------------------------------------------------------------------------------
javascript's condition must within ()
-------------------------------------------------------------------------------------------
must use the return statement to return the function value.
-------------------------------------------------------------------------------------------
javascript loops:
1.for
2.while
3.do...while
for (variable in object)
{
code to be executed
}
Example
var person={fname:"John",lname:"Doe",age:25};
for (x in person)
{
document.write(person[x] + " ");
}
-------------------------------------------------------------------------------------------
If the Boolean object has no initial value, or if the passed value is one of the following:
0
-0
null
""
false
undefined
NaN
-------------------------------------------------------------------------------------------
A cookie is a variable that is stored on the visitor's computer.
-------------------------------------------------------------------------------------------
在学习过程中忘记了递归。。。。
In the HTML DOM, each node is an object.
-------------------------------------------------------------------------------------------
The most important node types are:
Element type NodeType
Element 1
Attribute 2
Text 3
Comment 8
Document 9
-------------------------------------------------------------------------------------------
Jump to Line
Something went wrong with that request. Please try again.