我需要从一个数组中删除一个项目,然后将其放入另一个数组的顶部。
我目前有一系列文章,其中一些文章的类型英雄是真实的,而其他文章则是常规的。我需要找到数组中的第一篇英雄文章并将其删除。然后把这篇文章放到另一个数组的顶部。任何帮助将非常感激。谢谢
我目前有这个:
articles = [
{title: "article 1", hero: false},
{title: "article 2", hero: false},
{title: "article 3", hero: true},
{title: "article 4", hero: false},
{title: "article 5", hero: true},
{title: "article 6", hero: false},
{title: "article 7", hero: true}
]
但想要这个结果:
articles = [
{title: "article 1", hero: false},
{title: "article 2", hero: false},
{title: "article 4", hero: false},
{title: "article 5", hero: true},
{title: "article 6", hero: false},
{title: "article 7", hero: true}
]
hero = [
{title: "article 3", hero: true}
]
白衣染霜花
慕的地8271018
相关分类