Object-oriented in JavaScript

Source: Internet
Author: User

    //Simple Object-orientedFunction Constructor () { This. Properties; }    //The properties written in the constructor are generally public properties, or are changed by passing values. constructors-prototypes-Methods=function () {}; //The method written on the prototype is a public method,//when creating an object, the public method is copied to the newly created object .//The method created on the prototype can improve performance, only one copy is present in memory    varObject 1 =Newconstructor function ();    Object 1. Method (); function fn (name) { This. Name =name; }    //fn.prototype.constructor = fn;Fn.prototype.showName=function () {alert ( This. Name); }    varObj1 =Newfn"Xiao Ming" );    Obj1.showname (); varObj2 =Newfn"Job" );    Obj2.showname (); Write the normal method first and then convert it into an object-oriented notation1the global variable is written in the attribute.2. Functions are methods3. Creating an object in onload4. Modify this to point to an issue

Object-oriented in JavaScript

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.