class继承

xml 复制代码
<script>
    class Point {
       constructor(x, y) {
          this.x = x
          this.y = y
       }
       say() {
          console.log("我父类方法");
       }
    }
    class ColorPoint extends Point {
       //子类继承父类,必须实现构造函数
       constructor(x,y,z){
          super(x,y)
          this.z = z  
       }
       hi(){
          super.say()//调用父类方法
       }
    }
    const p = new ColorPoint(10,20)
    p.hi()
    // console.log(p.x);
</script>
相关推荐
_lucas1 分钟前
给知识库网站接入AI问答
前端·ai编程·全栈
前端糕手39 分钟前
前端面试题大全:JavaScript + Vue3 + React + TypeScript + 工程化 + 性能优化
前端
我不叫武2 小时前
一个用 Rust 写的离线编码查询桌面工具
前端
Web4Browser3 小时前
指纹浏览器 API 自动化怎么接:启动 Profile、获取 CDP 端点并连接自动化框架
前端·网络·typescript·自动化
Patrick_Wilson3 小时前
从 React 到 Flutter:写给前端的一张跨端知识地图
前端·flutter·react.js
颜酱3 小时前
06 | 把 meta_config 同步进 MySQL(生成阶段)
前端·人工智能·后端
OpenTiny社区3 小时前
Loop Engineering:让 AI Agent 自己跑起来的工程方法
前端·github
IT_陈寒4 小时前
SpringBoot自动配置坑了我一周,原来问题这么蠢!
前端·人工智能·后端
kyriewen4 小时前
我review了一份Vibe Coding写的前端代码——能跑,但5个地方迟早要命
前端·javascript·ai编程
REDcker5 小时前
Cesium三维WebGIS入门详解
前端·gis·web·cesium·webgis