var id = ''
var tagList = [{"parentTagId":"","parentTagName":"学校","childTagId":"","childTagName":"高中"},
{"parentTagId":"","parentTagName":"学校","childTagId":"","childTagName":"初中"}]
for(var i = ; i < tagList.length; i++){
if(tagList[i].childTagId === id){
tagList.splice(i,);
}
}
console.log(JSON.stringify(tagList))

或者直接是哪对象过来也行,一样的方法:

var obj = {
parentTagId : '',
parentTagName:"学校",
childTagId: '',
childTagName:"高中"
}
var tagList = [{"parentTagId":"","parentTagName":"学校","childTagId":"","childTagName":"高中"},
{"parentTagId":"","parentTagName":"学校","childTagId":"","childTagName":"初中"}]
for(var i = ; i < tagList.length; i++){
if(tagList[i].childTagId === obj.childTagId){
tagList.splice(i,);
}
}
console.log(JSON.stringify(tagList))

js删除数组中某一项,splice()的更多相关文章

  1. js删除数组中元素 delete 和splice的区别

    例如我有一个数组: var array = ["aa","dd","cc","aa"] ,我想删除这个数组的“dd”元素 ...

  2. 记录:js删除数组中某一项或几项的几种方法

    1:js中的splice方法 splice(index,len,[item])    注释:该方法会改变原始数组. splice有3个参数,它也可以用来替换/删除/添加数组内某一个或者几个值 inde ...

  3. 记录:js删除数组中某一项或几项的几种方法(转)

    1:js中的splice方法 splice(index,len,[item])    注释:该方法会改变原始数组. splice有3个参数,它也可以用来替换/删除/添加数组内某一个或者几个值 inde ...

  4. js删除数组中某一项或几项的几种方法

    1:js中的splice方法 splice(index,len,[item])    注释:该方法会改变原始数组. splice有3个参数,它也可以用来替换/删除/添加数组内某一个或者几个值 inde ...

  5. JS删除数组中某一项或几项的方法汇总

    1.JS中的splice方法 splice(index, len, [item])    //注意:该方法会改变原始数组. splice有3个参数,它也可以用来替换/删除/添加数组内某一个或者几个值. ...

  6. js 删除数组中某一项的几种方法总结

    第一种:改变原数组 借用原生数组方法:splice(index,len,[item])  剪接 借用原生对象方法:delete array[index] + array.slice(0, index) ...

  7. js 删除 数组中某个元素(转载)

    来源:https://www.jb51.net/article/134312.htm js删除数组中某一项或几项的几种方法 https://www.jb51.net/article/154737.ht ...

  8. js删除数组中元素的方法

    一.清空数组 var ary = [1,2,3,4]; ary.splice(0,ary.length);//清空数组 console.log(ary); // 输出 [],空数组,即被清空了 二.删 ...

  9. js删除数组中的'NaN'

    js中的NaN不和任何值相等,包括自身. 所以可以使用x!=x来判断x是否是NaN,当且仅当x为NaN时,表达式的结果为true. NaN != NaN //true 可以依此删除数组中的'NaN'. ...

随机推荐

  1. Mapreduce报错:java.lang.ClassNotFoundException: Class Mapper not found

    mapreduce找不到mapper类 解决方法: 开始自己用的是mapreduce自己打包的一种方法: job.setJarByClass(StandardJob.class); 但这样一直在报错: ...

  2. transport.js报hasOwnProperty对象不支持此属性

    ECShop transport.js错误 这次出现的问题是transport.js在IE下提示对象不支持该用法.出现错误位置为608行的下面的代码: if(this.hasOwnProperty(k ...

  3. [Angular] Introduction to Angular Internationalization (i18n)

    To add translation to the application: <button (click)="onEditCourse()" i18n>Edit bu ...

  4. [Functional Programming ADT] Adapt Redux Actions/Reducers for Use with the State ADT

    By using the State ADT to define how our application state transitions over time, we clear up the ne ...

  5. [Algorithm] Find Max Items and Max Height of a Completely Balanced Binary Tree

    A balanced binary tree is something that is used very commonly in analysis of computer science algor ...

  6. [ES6] 10. Array Comprehensions

    ES6 decided that Array Comprehensions will not included in this version, ES7 will include this. Ther ...

  7. Rails 枚举

    Rails Model中使用枚举有两种方案,一种是rails内置的enum,一种使用enumerize这个gem,不管哪种都能达到相同的目的. 首先介绍第一种: 一. enum 基本使用方法,以一个案 ...

  8. google,百度地图POI下载

    百度,google POI下载工具是可以对任意矩形范围,以及任意省市级区域的兴趣点数据进行下载,可以支持多线程下载,按分类下载,以及按关键字下载. 线程数可以自由设置16线程之内.下载格式为excel ...

  9. 史上最牛逼的纯CSS实现tab选项卡,闪瞎你的狗眼

    下载地址:http://download.csdn.net/detail/cometwo/9393614 html文件 <!DOCTYPE html> <html> <h ...

  10. 【Linux命令】ls命令

    ls命令是Linux最常用的命令,ls命令就是list的缩写,主要作用是:打印出当前目录的清单.如果ls指定其他目录,那么就会显示指定目录下的清单. 1.命令格式 ls [选项] [目录名] 2.命令 ...