【发布时间】:2013-03-10 17:34:34
【问题描述】:
有没有办法检查谷歌应用脚本中的内置类型? 我不知道如何访问内置类型的构造函数。所以我不能使用 instaceof 操作符。
例如个人资料(https://developers.google.com/apps-script/class_analytics_v3_schema_profile)
function getReportDataForProfile(profile) {
if (profile instanceof Profile) // Profile is undefined...
...
}
还有什么有点令人困惑:当我获得 Profile 的实例时(在变量配置文件中)
profile.constructor // is undefined
【问题讨论】:
-
为什么需要 Profile 构造函数?你想做什么?
-
我不确定是否需要构造函数。我想测试配置文件(函数参数)是否是配置文件的实例。当然这只是例子。我想为任何对象执行此操作。虽然“鸭子打字”总是可能的,但我希望有一些简单的解决方案。