多个对象未显示
Multiple objects aren't getting displayed
我一直在摆弄 Javascript 中的对象,但遇到了一个问题。基本上,我试图从我创建的对象中打印某些属性,但它无法正常工作。
代码如下:
function Hotel(name, rooms, booked) {
this.name = name;
this.rooms = rooms;
this.booked = booked;
var CanadaHotel = new Hotel("CanadaIn", 50, 10);
var AmericanHotel = new Hotel("AmericanIn", 60, 3);
document.write(CanadaHotel.rooms);
document.write(AmericanHotel.booked);
None 的属性正在显示,我不知道为什么.. 非常感谢任何帮助。
谢谢
SyntaxError: missing } after function body
固定
function Hotel(name, rooms, booked) {
this.name = name;
this.rooms = rooms;
this.booked = booked;
}
var CanadaHotel = new Hotel("CanadaIn", 50, 10);
var AmericanHotel = new Hotel("AmericanIn", 60, 3);
console.log(CanadaHotel.rooms);
console.log(AmericanHotel.booked);
我一直在摆弄 Javascript 中的对象,但遇到了一个问题。基本上,我试图从我创建的对象中打印某些属性,但它无法正常工作。
代码如下:
function Hotel(name, rooms, booked) {
this.name = name;
this.rooms = rooms;
this.booked = booked;
var CanadaHotel = new Hotel("CanadaIn", 50, 10);
var AmericanHotel = new Hotel("AmericanIn", 60, 3);
document.write(CanadaHotel.rooms);
document.write(AmericanHotel.booked);
None 的属性正在显示,我不知道为什么.. 非常感谢任何帮助。
谢谢
SyntaxError: missing } after function body
固定
function Hotel(name, rooms, booked) {
this.name = name;
this.rooms = rooms;
this.booked = booked;
}
var CanadaHotel = new Hotel("CanadaIn", 50, 10);
var AmericanHotel = new Hotel("AmericanIn", 60, 3);
console.log(CanadaHotel.rooms);
console.log(AmericanHotel.booked);