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)