一、The differencs between JavaScript and classic OO language
There is a difference between JavaScript and the "classic" OO languages like c++ and Java.You should understand right form the start that in JavaScript there are no classes; everything is based on objects.
In classic OO language: "create me a new object called Bob which is of class Person"
In a prototypal OO language: "I am going to take this object Person that I have lying around and reuse it as a prototype for a new object that i will call Bob" .
二、Primitive date types
。There are five primitive date types in JavaScript
. number(it contains positive and negative integers or floats/hex/oct/exponents/NaN/Infinity/-Infinity)
. string(it contains charactere)
. boolean(only contains true and false)
. undefined(the values that have been defined but not been initialized or the value that doesn't exist)
. null(the value is null)
。 Everything that is not a primiary is an object
三、For in
This loop just like for each that in Java language.
EXP:var s = "happyjlq";
for(var args in s){
console.log(s[args]);
}
四、Comments
Some examples:
//beginning of the line
var s = 234;// anywhere in the line
/*multi-line comment on a single line*/
/*
comment
several lines
*/
五、operators
Arithmetic operators: +, -, *, /, and %.
Increment operators: ++ and --.
Assignment operators: =, +=, -=, *=, /=, and %=.
Special operators: typeof and delete.
Logical operators: &&, ||, and !.
Comparison operators: ==, ===, !=, !==, <, >, >=, and <=.