ES6class
<script>
class SmartPhone{
constructor( name, company ){
this.name = name;
this.company = company;
this.version = 10;
}
varsionUp = function(){
this.version += 1;
}
}
class Samsung extends SmartPhone{
}
let iphone = new SmartPhone( 'iphone', 'Apple', 10 );
//console 창에 let galaxy = new Samsung( 'galaxy', 'Samsung', 's10' );
class Mavel{
hero(){
return 'Super-man'
}
}
class Dc extends Mavel{
hero(){
return 'Batman'
}
}
const dc = new Dc();
console.log( dc.hero() );
///console 확인 => Batman
</script>
ES6 super
<script>
//super
class Mavel{
hero(){
return 'Super-man'
}
}
class Dc extends Mavel{
hero(){
return super.hero();
}
}
const dc = new Dc();
console.log( dc.hero() );
///console 확인 => Super-man
</script>
'javascript > es6' 카테고리의 다른 글
es6 filter, includes, from 사용 (0) | 2020.07.16 |
---|