实例代码“Ctrl+/”提示“F11/ESC”全屏 返回 格式化 恢复 运行
x
 
1
<!DOCTYPE html>
2
<html>
3
<body>
4
5
<p id="demo">Click the button to create an array, call the new ucase() method, and display the result.</p>
6
7
<button onclick="myFunction()">Try it</button>
8
9
<script>
10
Array.prototype.myUcase=function()
11
{
12
for (i=0;i<this.length;i++)
13
  {
14
  this[i]=this[i].toUpperCase();
15
  }
16
}
17
18
function myFunction()
19
{
20
var fruits = ["Banana", "Orange", "Apple", "Mango"];
21
fruits.myUcase();
22
var x=document.getElementById("demo");
23
x.innerHTML=fruits;
24
}
25
</script>
26
27
</body>
28
</html>