Speak dry, not long-winded, the prototype can get to the prototype object of JavaScript, then you can add new properties and methods on the object prototype, when the method and the original method name as overwrites the original method both: rewrite , when not the same when both: Add
Such as: to achieve push method Array The array of overwriting
Array.prototype.push = function() { for( let i = 0 ; i < arguments.length ; i++){ this[this.length] = arguments[i] ;//arguments为传参数组列表 } return this.length; }
Limited capacity, the general level, mistakes, please correct me, thanks to the attention and comment!