prototype Constructor Date() prototype属性允许您向任何对象添加属性和方法(Number,Boolean,String,Date等)。注意:Prototype是一个全局属性,几乎可用于所有对象。 语法 object.prototype.name = value 例如:Date.prototype var myBook = new book("Perl", "Mohtashim"); book.prototype.price = null; myBook.price = 100; console.log("Book title is : " + myBook.title + "<br>"); console.log("Book author is : " + myBook.author + "<br>"); console.log("Book price is : " + myBook.price + "<br>"); 成功执行上述代码后,将显示以下输出。 Book title is : Perl Book author is : Mohtashim Book price is : 100 Constructor Date()