检查Ember.js:获取对象的types(Class)?
我使用console.log()很多,特别是与Ember.inspect()结合使用。 但有一件事我想念: 
我怎样才能找出一个对象(类)的types?
 例如:在检查Ember.get("controller")时得到类似于<Sandbox.ApplicationController:ember288>东西? 
这是Ember数据1.0.0-beta.17 +( 他们改变了 )
 如果您只想要模型名称(例如, App.Comemnt或app/models/comment.js具有型号名称comment ),则可以使用thing.constructor.modelName 。 
例如:
 var aComment = this.get('store').createRecord('comment'); aComment.get('constructor.modelName') // => 'comment' 
这是Ember数据1.0.0.beta.3
 如果你只是想要types键(例如, App.Comment的types键是comment ),你可以使用thing.constructor.typeKey 。 
例如:
 var aComment = this.get('store').createRecord('comment'); aComment.get('constructor.typeKey') // => 'comment' 
我知道你正在寻找一个string用于debugging目的,但我最初来到这个问题,想知道如何获得对象的types,而不是描述对象的string。
使用内置的Javascript属性构造函数将产生用于构造实例的类。 比如你可以这样做:
 person = App.Person.create(); person.constructor // returns App.Person person.constructor.toString() // return "App.Person" 
 如果你得到Class ,你通常可以调用toString() (或者作为一个快捷方式concat一个空string+ '' )来获取类似于<Sandbox.ApplicationController:ember288> 
 另一个有用的function(在铬)是dir命令。 
 dir(App.User) 
这将给你完整的对象信息,而不仅仅是名称。