其他分享
首页 > 其他分享> > 构造函数的显性返回的记录【2021.12.9】

构造函数的显性返回的记录【2021.12.9】

作者:互联网

// 1
    function Name(name){
        this.name = name;
        return new_name={
            name:'彭大',
        }
    }
    let MyName=new Name("pfq");
    console.log(MyName.name)//彭大
    console.log(new_name.name)//彭大
// 2
    function Age(age){
        this.age=age;
        return new_age=['a','b','c']
    }
    let MyAge = new Age(18);
    console.log(MyAge.age)//undefined
// 3
   
    function Height(height){
        this.height= height;
        return function(){
            return  new_height=18;
        }
    }
    let MyHeight = new Height(16);
    console.log(new Height(17).height)//undefined
    console.log(MyHeight())//undefined

标签:console,name,2021.12,age,height,log,new,构造函数,显性
来源: https://blog.csdn.net/masierty/article/details/121921651