js how to safely extend the system function

If the direct expansion system using a prototype function, and others may be conflicting code

To prevent conflicts, it can be extended using the following method:

 

function MyArray(){

  this.Name="MyArray";

}

MyArray.prototype=[];

 

--------------------------------------

var arr =new MyArray();

arr.push(1);

 

Guess you like

Origin www.cnblogs.com/fanfan-90/p/11921773.html