Skip to content

Instantly share code, notes, and snippets.

@flipjs
Created January 25, 2016 23:56
Show Gist options
  • Save flipjs/a756c64ca9f609b0d5ec to your computer and use it in GitHub Desktop.
Save flipjs/a756c64ca9f609b0d5ec to your computer and use it in GitHub Desktop.
filter-data
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