javascript - JS无名类及其无名扩展类
问题描述
Operation
class 创建一个像这样的数组,它在数组之前没有类名。
[operInputQuery[0].value, operInputQuery[1].value, operInputQuery[2].value]
'Table' 类旨在成为继承Operation
' 构造函数的未命名类。
它可以正确继承,但是,它会extends
像这样使用不必要的标签创建数组。
extends[operInputQuery[0].value, operInputQuery[1].value, operInputQuery[2].value, operInputQuery[3].value]
是的,我不想用“扩展”的东西创建数组。
如何创建一个未命名的扩展类?
let Operation = class { //unamed class
constructor(a, b, c) {
this.a = operInputQuery[0].value;
this.b = operInputQuery[1].value;
this.c = operInputQuery[2].value;
}
}
let Table = class extends Operation { //purposed to write an unnmaed extended class
constructor(a, b, c, d){
super(a, b, c);
this.a;
this.b;
this.c;
this.d = operInputQuery[3].value;
}
};
解决方案
operInputQuery 丢失,但我猜是具有 value 属性的对象数组,试试这个:
let operInputQuery = [{value: 1}, {value: 2}, {value: 3}, {value: 4}];
let Table = class {
constructor(a, b, c, d){
this.a = a;
this.b = b;
this.c = c;
this.d = d;
}
};
let table = new Table(operInputQuery[0].value, operInputQuery[1].value, operInputQuery[2].value, operInputQuery[3].value);
console.log(table);
推荐阅读
- java - 每次调用 notifyDataSetChanged() 时,都会调用 onBindViewHolder()
- python - 如何在不影响其他人的情况下冻结pygame中的特定实例
- python - Python2:我想在 dict o/p 中添加一些字符串
- python - 从 tensorflow.js 中的 csv 数据中删除重复行
- javascript - 使用springmvc框架的jQuery Ajax文件上传返回415
- swift - Swift 自动执行异步
- html - 将网页元素复制或导出为 html 文件......这有可能吗?
- variables - Terraform 默认地图值
- javascript - 使用javascript的登录界面
- session - 在 keycloak 中自定义用户会话数据