JavaScript Basics XV (prototype chain batch set public properties)

Source: Internet
Author: User

  functionFn () { This. x = 100; }     /*1. Assign the original prototype address to our pro, and now they are working with the same memory space*/       varPro =Fn.prototype; Pro.geta=function(){}; Pro.getb=function(){}; Pro.getc=function(){}; /*2. The way to reconstruct the prototype and own a new heap of memory, store our public, properties and methods, the browser was originally opened to the Fn.prototype to replace the*/Fn.prototype={       //only the browser is born to Fn.prototype in the heap memory of constructor, and we       //This heap of self-opened memory does not have this property, so constructor point is not FN but       //object.       //F.constructor didn't do any processing before Object       //in order to be consistent with the original, we need to manually increase the point of constructorConstructor:fn, PROTOTYPE:FN, GetX=function() {}, GetY=function() {}, GetZ=function(){}               }; //2, in this way to add to the built-in class so good mouth love public properties        //Adding an array to the built-in class arrary the method of weight       //`````````````````````````````````````````````````       //this way we replace the properties and methods that were already present in the prototype, so our       //If you modify the built-in class this way, the browser is the one that you want to block out.        //But we can modify the built-in method each time, when we add the method to the array prototype by the following way        //if the method name and the original built-in repetition, it will be built-in changes to others-and we later built the prototype of the class        //Add a method, name all need to add special prefix MyuniqueArray.prototype ={constructor:array, unique:function(){           }       };

JavaScript Basics XV (prototype chain batch set public properties)

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.