Last Updated: February 25, 2016
·
3.353K
· ulisesrmzroche

Don't forget about Ember.typeOf()

Ember.TypeOf() returns a consistent type for the passed item across all browsers. It adds a bit more detail to the return value and can make checks on Ember.Object (classes and instances) It uses the duck-typing technique of toString(), which returns [object [Class]], and then matches via a regex.

Examples

Ember.typeOf() // => 'undefined'
Ember.typeOf('string') // => 'string'
Ember.typeOf({a: "b"}) // => 'object'
Ember.typeOf(undefined) // => 'undefined'