Ext JS Learning the fifth day we are familiar with JavaScript (iv)

Source: Internet
Author: User

This article is used to record learning notes;

JavaScript Object, Object-oriented • Possible for high-level languages you may know or even master OOP object-oriented, so how much do you know about JavaScript? Together we learn JavaScript object-oriented, which helps us understand the infrastructure of EXT, Ext itself is a JS object-oriented framework. • Using JSON object (JavaScript object Notation) –js Object-JSON object is very important for JS, we have to learn how to manipulate JSON objects • Object-oriented concepts-how to define a class, how to instantiate an object, how to extend an object ( Prototype prototype) – Monomer mode: Simple monomer, closure monomer, inert monomer, branching monomer – Definition of object other ways (factory model, secure object, aggregated object) – Use of prototypes, prototype chains – Inheritance of prototypes (multiple implementations: Combined inheritance, borrowing of constructor inheritance, mixed inheritance, Mixed elements, etc.) – chained programming –javascript contract: Interface (annotation method, attribute detection method, Duck type method) • Design mode: If you can master JS design mode, I believe that in the future of ext learning, slowly study, realize the design of ext code, is very helpful. Attach some chestnut codes
1 Ext.onready (function () {2     //var obj = new Object ();3     varobj = {Name:'Z3', Age: -};//JSON Object4Obj.sex ='male';//New Properties5Obj.age = -;//Modifying the value of a property6Delete Obj.name;//delete an object's properties7     8     //enumerating the loops of an object's built-in properties9      for(varattrinchobj) {TenAlert (attr +" : "+obj[attr]); One     } A  -     //defines a JS class -     varperson =function (name, age) { the          This. Name =name; -          This. Age =Age ; -         //Private -         var_sex ='male';//JS's Private property +          This. Getsex =function () { -             return_sex;  +         }; A          This. Setsex =function (Sex) { at_sex =sex; -         }; -     }; - //Person.prototype.id = 10;  - //Person.prototype.method = function () { - //alert (this.age); in //    }; -      to     //the constructor of the prototype object always points to the template of the current object +Person.prototype = { - Constructor:person, theId:Ten ,  * method:function () { $Alert'method ....');Panax Notoginseng         }  -     };  the  +      A     //instantiate an object the     varp =NewPerson ('Zhang San', -); + alert (p.name); - alert (p.id); $ P.method (); $      -      -     //Monomer mode: Simple monomer the     varSXT = {}; -SXT. Array = {Wuyi each:function () { theAlert'Each ....'); -         }, Wu filter:function () { -Alert'Filter ...'); About         } $     }; -Sxt.staticmethod =function () { -Alert'I am a static method under the monomer! '); -     }; A      + SXT. Array.each (); the Sxt.staticmethod (); -      $     //monomer mode: Closed-Package monomer the     varSXT =(function () { the         varArray = { the each:function () { theAlert'Each ...'); -             } in         }; the         return { the arrayeach:function () { About Array.each (); the             } the         }; the     })(); + Sxt.arrayeach (); -      the});

Recommended to you a beautiful article network www.fishcmonkey.com, learning to improve the literary accomplishment.

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.