JS Prototype Object Chapter

Source: Internet
Author: User

All objects

The value type in JS is not the object that remains the object (that is, the reference type)

The typeof () operator determines four types of values

typeof 10;   --Number | | typeof "Ten"-->string | | typeof true--Boolean | | typeof X--undefined

typeof (Funciton () {})--function

typeof ([+])--Object

typeof ({a:1,b:2})---Object

typeof (Null)--Object

typeof (new number)--Object//

Judging a variable is not an object very simple value type use typeof () to judge the reference type with instanceof ()

Note: The rule of instanceof () operator : A instanceof B is the prototype property of a constructor pointing to an object that has another prototype chain to detect the object on?

A is the object B is generally a constructor, along the __proto__ of a (invisible prototype) up the first look up, while along the prototype line B to find, if both can find the same reference, return True

collection of several properties of the object

In JavaScript, an array is an object, a function is an object, an object is an object, and a property is represented as a key-value pair, so the difference between a property method and a later key value is different.

var obj = {
A:10,
B:function () {},
C: {
Name: "Liuxiankun",
year:1992
},
};

Obj is a custom object with a B C three properties, the value of the C property is an object, and there are two properties

Functions and arrays are also objects that cannot be defined with the above method (because the above custom object is an instance of new object), but as long as the object is a collection of properties

function as an example

var fn = function () {}

Fn.a = 10;

fn.b = Funciton () {}

FN.C = {
Name: "Liuxiankun",
year:1992
}

The function in the above code is assigned a value of three properties. A collection of properties that are obviously

$.trim in jquery ()

$ is a function in itself

$.trim () is the value of a property property on a function.

JS Prototype Object Chapter

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.