1.function 构造函数名(){
    this.属性=值;
    this.方法=function(){}
    }
    2.new 构造函数名();
    3.构造函数名首字母大写
    4.调用构造函数必须要用new
    5.属性和方法前面必须添加this. 谁new(实例化)就指向谁
    6.可以利用new Star()重复调用

    1. function Star(){
    2. this.name=uname;
    3. this.age=age;
    4. this.sex=sex;
    5. this.sing=function(simg){
    6. console.log(sing)
    7. }
    8. }
    9. var ldh =new Star("刘德华",18,"男");
    10. var zxy =new Star("张学友",20,"男");
    11. console.log(ldh["name"]); //或者console.log(ldh.name)
    12. console.log(ldh);
    13. ldh.sing("冰雨");
    1. <script>
    2. function Student(name,age){
    3. this.name=name;
    4. this.age=age;
    5. }
    6. //this指实例化的对象
    7. var liu=new Student("刘德华",18);
    8. console.log(liu);
    9. console.log(liu.name); //读取对象的属性
    10. </script>

    image.png