js创建Object的两种方式

    xiaoxiao2021-03-25  104

    //方法一:使用new操作符后跟Object构造函数    var people=new Object();   //也可以用 var people={}; 效果一样   people.name="windy";   people.age=19;   alert(people.name);   alert(people.age);    //方法二:使用对象字面量的表示法       var man={             name:"justin",   age:20   }   alert(man.name);   alert(man.age);
    转载请注明原文地址: https://ju.6miu.com/read-9202.html

    最新回复(0)