Javascrpt Class-oriented objects

Source: Internet
Author: User

As the object-oriented language of the most important or object-like concept of the idea of the importance
This explains the class in JS:
We usually say a person:

What characteristics do people have as a normal person
There must be a name, age, ID number.
But a man's name cannot be said to be fixed, everyone's name is different.
The general concept of human being is the class and concrete to everyone is instantiation (new)
Then we can write a person this class this is just a general vague concept of a person

function Person (name, age, id) {    this. Name = name;      this. Age = Age ;     this. id = ID;}

Besides these attributes, people have their own skills in JS which we call methods (function) such as eating and walking

function () {    console.log (' work ');  }

So specifically to everyone, we're going to give you an example of how to instantiate a Tom when he has a specific age ID name.

var New Person (' Tom ', ' 12 ', ' 123456798 ');
Tom.work ();

Javascrpt Class-oriented objects

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.