一、类的定义

 class Parent{
constructor(name="mukewang"){
this.name=name;
}
} let v_parant=new Parent("v");
console.log("constructor",v_parant);

类的继承

// extends 用于继承父类

 //继承
class Parent{
constructor(name="mukewang"){
this.name=name;
}
} class Child extends Parent{ } console.log("extend", new Child()); //继承传递参数
//super必须放在设置改变参数的前面
{
class Parent{
constructor(name="mukewang"){
this.name=name;
}
} class Child extends Parent{
constructor(name="child"){
super(name);
this.type="child"
}
} console.log("extend", new Child("hello"));
}

  

get 、set 方法

    //getter,setter
class Parent{
constructor(name="mukewang"){
this.name=name;
}
get longName(){
return "mk"+this.name
}
set longName(value){
this.name=value;
}
} let v=new Parent();
console.log("getter",v.longName);
v.longName="hello"
console.log("getter",v.longName);

 静态方法

//静态方法
class Parent{
constructor(name="numewang"){
this.name=name;
} static tell(){
console.log("tell");
}
}
Parent.tell(); //静态属性
class Parent{
constructor(name="numewang"){
this.name=name;
} static tell(){
console.log("tell");
}
} Parent.type="test";
console.log("静态属性",Parent.type);
}

  

  

 

  

  

最新文章

  1. hdu5438 Ponds dfs 2015changchun网络赛
  2. Angular JS中的依赖注入
  3. (新人的第一篇博客)树状数组中lowbit(i)=i&(-i) 的简单文字证明
  4. 【MySQL】MySQL复制表结构、表数据
  5. HDU 5059 Harry And Biological Teacher
  6. 批量创建客户主数据函数SD_CUSTOMER_MAINTAIN_ALL
  7. (转)解决png图片在IE6下不透明的方法
  8. I题 - A+B for Input-Output Practice (VIII)
  9. Nginx教程(四) Location配置与ReWrite语法
  10. C#泛型集合之List
  11. Caffe + Ubuntu 15.04 + CUDA 7.0 安装以及配置
  12. 幽灵自建的html5 的模板文件!
  13. MySQL服务无法启动 3534
  14. 第三章 jQuery总结 参考文本
  15. Java笔记一JAVA安装环境变量配置
  16. [leetcode]3. Longest Substring Without Repeating Characters无重复字母的最长子串
  17. python模块分析之logging日志(四)
  18. Linux 命令locate
  19. def chi(*food,**kw):
  20. mongodb lock 出毛病时解决方法

热门文章

  1. 【6】.net msmq消息队列实例
  2. spring设置字符编码过滤器
  3. mysql自定义变量
  4. python打开文件常见错误及解决办法
  5. IndexedDB(一:基本使用)
  6. js实现浏览器窗口缩放刷新
  7. sass判断语句
  8. Git Bash Here常用命令以及使用步骤
  9. 新项目放到jenkins步骤
  10. 多尺度几何分析(Ridgelet、Curvelet、Contourlet、Bandelet、Wedgelet、Beamlet)