0
我有這樣的陣列的Javascript鑄造
var myArr = [];
myArr[0] = 'hello world';
myArr[1] = 'hello universe';
然後我想myArr,該[1]元素轉換爲大寫我應該怎麼做呢?
我可以用
document.write(myArr[1].toUpperCase());
,或者我應該使用
document.write(String(myArr[1]).toUpperCase());
是什麼在性能方面更好?
做'String(myArr [1])''服務的目的是什麼? – aug
當然document.write(myArr [1] .toUpperCase());因爲myarray已經在字符串中了,所以不需要在字符串中進行轉換 –