📜  括号符号示例 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:02:43.403000             🧑  作者: Mango

代码示例1
let cargoHold = ['oxygen tanks', 'space suits', 'parrot', 
                 'instruction manual', 'meal packs', 'slinky', 
                 'security blanket'];

/*a) Use bracket notation to replace ‘slinky’ with ‘space tether’. 
Print the array to confirm the change.*/

cargoHold[5] = "space tether"; 
console.log(cargoHold); 

//OR// cargoHold.splice(5,1, 'space tether');
// console.log(cargoHold);