js 数组中如何删除字典
Posted Mr Riven
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了js 数组中如何删除字典相关的知识,希望对你有一定的参考价值。
区别:
[]表示是一个数组,如var strs = [‘a‘,‘b‘,‘c‘]。{}表示是一个对象,比如,
var obj = {
name: ‘宙斯‘,
sex: 1
}
如何在数组中删除指定对象呢??
[
{
"id": 12,
"title": "fdsfsdds",
"markdown": "fsdafafs",
"counttet": "fsdafafs"
},
{
"id": 13,
"title": "fdsfsdds",
"markdown": "fsdafafs",
"counttet": "fsdafafs"
},
{
"id": 14,
"title": "fdsfsdds",
"markdown": "fsdafafs",
"counttet": "fsdafafs"
},
{
"id": 16,
"title": "fdsfsdds",
"markdown": "fsdafafs",
"counttet": "fsdafafs"
},
]
方法: index可以是动态的,这样就能指定删除某一对象
splice(index,1)