Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

javascript filter method

var jsonarr = [
    {
        id: 1,
        name: "joe"
    },
    {
        id: -19,
        name: "john"
    },
    {
        id: 20,
        name: "james"
    },
    {
        id: 25,
        name: "jack"
    },
    {
        id: -10,
        name: "joseph"
    },
    {
        id: "not a number",
        name: "jimmy"
    },
    {
        id: null,
        name: "jeff"
    },
]
 
var result = jsonarr.filter(user => user.id > 0);
 
console.log(result);
Source by www.geeksforgeeks.org #
 
PREVIOUS NEXT
Tagged: #javascript #filter #method
ADD COMMENT
Topic
Name
1+5 =