javascript - ES6 反射中的 Type.GetType 等效项
问题描述
我最近读到了 ES6(符号、反射、代理)的元编程改进,它们确实很酷,但是我很难找到如何在 Type.GetType(细绳)。
ES6 中是否有等效选项?
背景是,如果我想使用反射来调用类的构造函数,我也希望以编程方式拥有该类型。
function commandFactory(name : string, args : CommandArgs) : Command {
let commandType = Type.GetType(name); /* theoretically speaking*/
return Reflect.construct(commandType, [args]);
}
提前致谢!
解决方案
推荐阅读
- go - 将 .xlsx 文件上传到谷歌云存储
- java - 如何从 firebase firestore 数据库中获取随机 qestion
- linux - 关于 traceroute 的返回值(或代替 nc 命令)
- python - 如何修复 python GUI 中的无响应错误
- xml - Powershell 生成 XML 文件
- sonos - 仅允许某些设备连接 Sonos 扬声器(Unifi 系统)
- java - SQL - 打印用户在字符串变量中给出的记录
- python - Powershell下运行pip和virtualenv(记事本窗口)
- ios - 如何在 swift 中使用 PageController 创建自定义的水平 UICollectionView
- android - 我们可以在我们的基础应用程序代码中访问按需动态模块的类/功能吗?