1
使用Google Closure继承范例我怎么能看到什么类名或我怎么能识别类,因为object.constructor.name
返回""
并且缩小时不正确?如何识别缩小的Google Closure代码中的课程?
其目的是执行代码依赖于接口或继承类的实现。此代码是延伸Animal
一个decorator类里面,也:
var object = XXX; // of @type {Animal}
switch (object.constructor.name) {
case 'Dog':
//...
break;
case 'Cat':
//...
break;
}
我目前的解决方案是为每个班级添加我自己的“标识符”。 – 2014-12-05 12:28:56