You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

能否将Task对象推入Project类内部的tasks数组?

问题:如何将Task类实例推入Project类的tasks数组?

我正在完成The Odin Project的todo list项目,已为此困扰近一个月,若此处不允许提问请告知,感谢。这并非作业,无评分要求,仅想推进项目。无需直接给出答案,相关技术文章或参考资料即可。

我希望将以下Task类的实例对象推入Project类的tasks数组中:

class Task {
  constructor(title, date, priority, desc) {
    this.title = title;
    this.date = date;
    this.priority = priority;
    this.desc = desc; 
  }
}

Project类代码如下:

class Project {
  constructor(name) {
    this.name = name;
    this.tasks = [];
  }
}

请问是否可以实现?我实在想不到方法。


内容的提问来源于stack exchange,提问作者shi shi

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.20 11:36:27