Java Script after Douglas Crockford ' s Training (JSON father)

Source: Internet
Author: User

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)

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.