Last Updated: February 25, 2016
·
3.654K
· 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'

Have a fresh tip? Share with Coderwall community!

Post
Post a tip
Did you know?

JavaScript on a page runs with the privileges of that origin. One altered library, tag manager, or snippet can read inputs, change what people see, and call your APIs as the user.

Security insights from Cside