Question: I have an array of objects and would like to check if a specific key/value exists, I'm currently using a for..in loop but was wondering if there is shorter/better way to do this?

**JS**

```
var models = [
  {
    "id": 1,
    "name": "James"
  },
  {
    "id": 2,
    "name": "Ken"
  },
  {
    "id": 3,
    "name": "Jason"
  }
];

function checkNameExists(name) {
    for( var model in models ) {
        if (models[model].name === name) {
            return true;
        }
    }
}

var nameExists = checkNameExists("Ken");

if(nameExists) {
    console.log('Name exists');
}

```

JSFiddle: <http://jsfiddle.net/kyllle/c21opmj8/1/>

Answer: 
You can use underscore's **some** function :

```
var nameExists = _.some(models, function (elem) {
            return elem.name == "Jason"
})

```

or in a shorter version as Ahmad Mageed suggested : 

```
var useFound = _.some(models,{ 'name': 'Jasonn' });

```

Here is a JSFiddle : <http://jsfiddle.net/c21opmj8/2/>
Without depending on external libraries, `Array.filter()` does the job:

```
models.filter( (x) => x.name==="Jason" )

```

`Array.find()` finds first occurrence and stops, hence it's faster.