02 空Array, 再添加

02 空Array, 再添加

var passiveComponent=[];
passiveComponent.push("Kiwi");
console.log(passiveComponent);



輸出:
["Kiwi"]

var fruits = ["Banana", "Orange", "Apple", "Mango"];
fruits.push("Kiwi");
console.log(fruits);

輸出:
["Banana", "Orange", "Apple", "Mango", "Kiwi"]


var arr = [
"apple",
"banana",
"cherry"
];

arr = arr.concat([
"dragonfruit",
"elderberry"
]);

console.log(arr);

輸出:
["apple", "banana", "cherry", "dragonfruit", "elderberry"]

javascript
01 String 字串CH04 ArrayCH05 時間日期Ch10 AJAX