본문 바로가기

⭐ JAVASCRIPT

javascript - class - constructor

class construct_test {
    constructor() {
        this.name = "짱구";
        this.age = 30;
        this.location = "인천광역시 서구 가정동"
        this.hobby = "영화 감상";
    }
}

    const aa = new construct_test();
        aa.age = "브라우니";
        aa.name = "김짱구"

    function test_01 () {
            const bb = new construct_test();
            const cc = "바보";
            const dd = "천재"; 
            // console.log(bb.name, bb.age, bb.hobby, bb.location);
            // console.log(bb);
            // console.log(cc);
            return dd; 
            // 리턴은 특정 변수값을 함수의 실행값으로 전달할 수 있기 때문에... 근데 맞는건가?
        }

    test_01();
        console.log(test_01());

# 결과값
"천재"