删除数组中一个元素,obj类型
、remove(object o)方法
功能:删除数组中一个元素,
参数:object 形如{"name":"张三"}
返回值: 删除指定元素后的数组
示例:[
{"name":"张三","age":"18"},
{"name":"李四","age":"19"},
{"name":"王五","age":"20"},
{"name":"六六","age":"18"}
].remove({"name":"李四","age":"19"})
结果:[
{"name":"张三","age":"18"},
{"name":"王五","age":"20"},
{"name":"六六","age":"18"}
]
尝试一下:
[
{"name":"张三","age":"18"},
{"name":"李四","age":"19"},
{"name":"王五","age":"20"},
{"name":"六六","age":"18"}
].remove({"name":"李四","age":"19"})
返回结果
删除数组中一个元素,值类型
、remove(value)方法
参数:也可以是值类型
返回值: 删除指定元素后的数组
示例:[1,2,3,4].remove(2)
结果:[1,3,4]
尝试一下:
[1,2,3,4].remove(2)
返回结果