javascript - find object by property from object array with grep function

voted: 0
array object find property grep

Object can be found with grep function:

var data = [
                {id: 1, text: 'javascript', color: "#1ebe56"},
                {id: 2, text: 'c#', color: "#336699"},
                {id: 3, text: 'php', color: "#555555"},
                {id: 4, text: 'cobol', color: "#336699"},
                {id: 5, text: 'ruby', color: "#555555"}

var item = $.grep(data, function (e) {
                    return e.text == "c#";

[Object { id=2,  text="c#",  color="#336699"}]
working url: not entered
version: not entered
Leave a Comment:
Characters left:
No comments yet.