ES6初识- Class

{
//基本定义和生成实例
class Parent{
//构造函数
constructor(name='lisi'){
this.name=name;
}
//属性get,set
get longName(){
return 'china'+this.name;
}
set longName(value){
this.name=value;
}
 
 
}
class Child extends Parent{
constructor(name='Child'){
super(name);
this.type='child';
}
}
let parent=new Parent(name='zhangsan');
console.log('parent',parent);
let child =new Child();
console.log("child",child);
}
{
class Parent{
//构造函数
constructor(name='lisi'){
this.name=name;
}
//属性get,set
get longName(){
return 'china'+this.name;
}
set longName(value){
this.name=value;
}
static tell(){
console.log("tell");
}
 
}
Parent.type="test";
Parent.tell();
}
posted @ 2017-11-26 22:22  浮云随笔  阅读(143)  评论(0编辑  收藏  举报