我正在做一个项目,目前正在学习 Javascript。现在,我想知道如何使用构造函数创建对象,为其分配属性,然后读取和修改这些属性。我想我的创建和分配部分是正确的,但我似乎无法从外部访问我的对象的任何属性。
function initialize() {
var testPlane = jet("9C3476", currentAirport, "Palma De Mallorca", "02:45", "Departed");
alert("Never get to this point: " + testPlane.id);
}
function jet(id, from, to, expected, status) {
this.id = id;
this.from = from;
this.to = to;
this.expected = expected;
this.status = status;
this.position = from;
alert("Id: "+ id + " From:" + from + " To: " + to + " Expected: " + expected + " Status: " + status);
this.marker = new google.maps.Marker({
position : this.position,
icon : img,
map : map,
});
}