📅  最后修改于: 2022-03-11 15:01:12.411000             🧑  作者: Mango
var newItem = "NEW_ITEM_TO_ARRAY";
var array = ["OLD_ITEM_1", "OLD_ITEM_2"];
array.indexOf(newItem) === -1 ? array.push(newItem) : console.log("This item already exists");
console.log(array)