Models

AJAX Abstraction for a Single Resource

has

The has() method can be used to get a true/false value based on whether an attribute exists on the model.

Values that are undefined or null will return false. Any other value will return true.

Default Implementation

The default implementation looks like this:

has: function(attr) {
  return this.get(attr) != null;
},

Usage

Let's use this code to illustrate:

import { Model } from 'lore-models';

const Tweet = Model.extend();

const tweet = new Tweet({
  id: 1,
  text: 'Some old tweet'
});

In the code above, tweet.has('text') will return true, whereas tweet.has('user') would return false because it's not defined.