示例:
head
如何将Id不为null的所有对象转换为新数组?
预期产出:
<style type="text/css">
答案 0 :(得分:1)
尝试使用_.filter
var Animals = [{Name: 'Dog', Id: 0},{Name: 'Cat', Id: 1},{Name: 'Mouse', Id:null}]
var newArray =_.filter(Animals ,a=> a.Id != null)
console.log(newArray)
&#13;
<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.11.2/lodash.min.js"></script>
&#13;