創(chuàng)建對(duì)象
var car = new Object();
var car = {};
var car = {
color : "red",
run : function(){alert("run")}
};
car.color; //"red"
car.run();//alert("run")
car["color"];
car["run"]();
增加屬性和方法
car.type = "suv";
修改
car.color = "white";
刪除
delete car.color;
元素構(gòu)建
car.constructor; //Object
constructor
var num = new Number(123);
num.constructor;//Number
toString
var num = new Number(123);
num.toString() //"123"
valueOf
var num = new Number(123);
num.valueOf(); //123
hasOwnProperty
var car = {
color : "red",
run : function(){alert("run")}
};
car.hasOwnProperty("color") //true
car.hasOwnProperty("logo") //false
最后編輯于 :
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者