![prototype [ˈprəʊtətaɪp] 原型 prototype [ˈprəʊtətaɪp] 原型](https://image.shishitao.com:8440/aHR0cHM6Ly9ia3FzaW1nLmlrYWZhbi5jb20vdXBsb2FkL2NoYXRncHQtcy5wbmc%2FIQ%3D%3D.png?!?w=700&webp=1)
<script>
Array.prototype.mysort = function(){
let s = this;
for(i=0;i<s.length;i++){
s[i] = parseInt(s[i]) + 1;
}
return s;
} var arr = new Array(6)
arr[0] = "3"
arr[1] = "1"
arr[2] = "4"
arr[3] = "6"
arr[4] = "2"
arr[5] = "3" console.log(arr.mysort());
</script>
此时的Array类型就有了一个mysort方法了