EcmaScript6 에서 class 기능이 추가됐다.

class Student{

    // 생성자.. 무조건 클래스명이 constructor
    constructor(name){
        this.name=name;
    }
      showName(){
        console.log(`내이름은 ${this.name} 입니다.`);
    }
}

let s1=new Student("limchard");
console.log("이름: "+s1.name);
s1.showName();

let s2=new Student("hoihoi");
console.log(`이름: ${s2.name}`);
s2.showName();
이름: limchard
내이름은 limchard 입니다.
이름: hoihoi
내이름은 hoihoi 입니다.
profile
java를 잡아...... 하... 이게 맞나...

0개의 댓글

Powered by GraphCDN, the GraphQL CDN