JavaScript Building Object Focus (i)

Source: Internet
Author: User

        
Person class
varperson ={making:function(name,age) { This. Name =name; This. Age =Age ; }, say:function() {document.write ( This. name+ "" + This. age+ ""); }}//Create the object's function, you need to pass two parameters, one is class (person), and one is the argument of the class. functionCreate (obj,arg) {functionCreate_inter () {obj.making.apply ( This, ARG); Create_inter is equivalent to integrating the person} create_inter. prototype=obj;//the person to Create_inter 's prototype.return New create_inter();//Returns the object that owns the person property and method created with Create_inter. }varSTU1 =NewCreate (person,["STU1", 20]);//STU1 varSTU2 =NewCreate (person,["STU2", 21]);//STU2 varSTU3 =NewCreate (person,["Stu3", 22]);//STU3Stu1.say (); Stu2.say (); Stu3.say ();

Need to continue to think about is: Stu1,stu2,stu3 in the Say () function is a common one, or each one? Remember to verify the code.
    

JavaScript Building Object Focus (i)

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.