tôi đặt nguyên mẫu của Array
như một thể hiện của my
, tôi nghĩ book.aa
sẽ hiển thị "aa"
, nhưng nó sẽ hiển thị "undefined"
, tại sao? Cảm ơn!Tại sao tôi không thể ghi đè nguyên mẫu của `Mảng` (` Array.prototype`)?
<html>
<head>
<title>Array Properties</title>
<h2>Array Properties</h2>
<script type="text/javascript">
function my() {
this.aa = 'aa';
}
Array.prototype = new my();
Array.prototype.bb = "bb";
var book = new Array();
book[0] = "War and Peace";
</script>
</head>
<body bgcolor="lightblue">
<script type="text/javascript">
document.write(book.aa+book.bb);
</script>
</body>
</html>