<html>
<body>
<h1>JavaScript 数组</h1>
<p>prototype 构造函数允许您向 Array() 对象添加新的属性或方法。</p>
<p id="demo"></p>
<script>
// 添加新方法
Array.prototype.myUcase = function() {
for (let i = 0; i < this.length; i++) {
this[i] = this[i].toUpperCase();
}
};
// 在任何数组上使用该方法
const fruits = ["Banana", "Orange", "Apple", "Mango"];
fruits.myUcase();
document.getElementById("demo").innerHTML = fruits;
</script>
</body>
</html>