Created
January 25, 2016 23:56
-
-
Save flipjs/a756c64ca9f609b0d5ec to your computer and use it in GitHub Desktop.
filter-data
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var data = [ | |
{ | |
id: 1, | |
name: 'felipe', | |
job: 'developer', | |
comment: 'hello world' | |
}, | |
{ | |
id: 2, | |
name: 'felipe', | |
job: 'ceo', | |
comment: 'quick test' | |
}, | |
{ | |
id: 3, | |
name: 'onie', | |
job: 'designer', | |
comment: 'hello test' | |
} | |
] | |
var search = 'fel' | |
var filter = data.filter(function (obj) { | |
return Object.keys(obj).some(function (item) { | |
return (obj[item].toString().indexOf(search) !== -1) | |
}) | |
}) | |
console.log(filter) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment