Lucky to participate in Daniel's training, learned a lot of things, summed up below:
1. The general idea is that every language has its own good and bad, and we have to avoid using the chaff part of the code and other ways. JS has a lot of shortcomings, but there are many advantages, we use his advantage is enough, do not go to the part of his shortcomings to add to your code
2. Each object is a collection of dynamic properties. Each attribute in the object has a unique key. Can be seen as a hashmap
All objects in 3.JS except (null and undefined)
How to create an object:
var my_object = {Foo:bar};
var my_object = object.defineproperties (
Object.create (Object.prototype), {
Foo: {
Value:bar,
Writeable:true,
Enumerable:true,
Configurable:true
}
});
4. There are two ways to obtain the attribute of an object (similar to set and delete)
get
Object.name
Object[expression] (this way to avoid use, to prevent injection attacks)
Set
Object.name = value;
Object[expression] = value;
Delete
Delete Object.name
Delete Object[expression]
5.prototypes
• You can create an object that you want
• Other objects can be inherited
customize his own object.
6.JS type inside (except for object)
number (numeric type, no int, long Double,etc) Boolean string array date RegExp function
7. Clear the difference between = = and = = =, recommend = = =
8.NaN
• Not a number
• Operating results for undefined or erroneous
nan equals nothing
Nan = = = Nan is False nan!== Nan is True
9.Arrays
array inherits from Object. indexes is converted to strings and used as names for retrieving values. very efficient for Sparse arrays. not very efficient in most other cases. one advantage:no need to provide a length or type when creating an Array.
。。。。。。 Cond
Java Script after Douglas Crockford ' s Training (JSON father)