JavaScript Series learning----Object Related concepts Understanding

Source: Internet
Author: User

1. Constructors (relative to classes in object-oriented programming languages)

2, object instance (it is the object constructed by the constructor, use to the keyword new)

3, this keyword (often refers to our object itself)

Let's look at an example:

var person = function person (living, age, gender) {

Below is the new object, which is being created (i.e. this = new object ();)

this.living = living;

This.age = age;

This.gender = gender;

This.getgender = function () {return this.gender;};

}

When the function was called with the New keyword ' This ' is returned instead of false

Instantiate a person object named Cody

var = new person (true, Cody, ' Male ');

Cody is a object and an instance of person ()

Console.log (typeof Cody); Logs Object

Console.log (Cody); Logs the internal properties and values of Cody

Console.log (Cody.constructor); Logs the person () function

JavaScript Series learning----Object Related concepts Understanding

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.