In Ember.js, I need to write a function that behaves differently depending on whether an object is an Ember Data object, or something else (Ember Object, plain JSON object, etc.). Is there a way to determine whether an object is Ember Data or not?
myfunction(myObject) {
if(isEmberData(myObject)) {
// Do stuff
} else {
// Do something else
}
}
A simple
if (obj instanceof DS.Model) {}
Should do the trick.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With