最佳答案
如果两个值都不存在,我如何推入数组?这是我的数组:
[
{ name: "tom", text: "tasty" },
{ name: "tom", text: "tasty" },
{ name: "tom", text: "tasty" },
{ name: "tom", text: "tasty" },
{ name: "tom", text: "tasty" }
]
如果我试图用name: "tom"
或text: "tasty"
再次推入数组,我不希望发生任何事情…但如果这两个都不存在,则我希望它.push()
我该怎么做呢?