<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>js arr_function</title> </head> <body> <p id="demo"></p> <button οnclick="f()">点我</button> <script> /*参考:https://www.cnblogs.com/1666818961-lxj/p/7404768.html*/ Array.prototype.upperCase = function () { // this,代表Array. for (let i = 0; i < this.length; i++) { this[i] = this[i].toUpperCase(); } }; function f() { let fruits = ["Banana", "Orange", "Apple", "Mango"]; fruits.upperCase(); let demo = document.getElementById("demo"); demo.innerHTML = fruits; // BANANA,ORANGE,APPLE,MANGO } </script> </body> </html>
js arr_function.html
猜你喜欢
转载自blog.csdn.net/weixin_42193179/article/details/105182162
今日推荐
周排行