我設置的Array
原型爲my
一個例子,我想book.aa
將顯示"aa"
,但它顯示"undefined"
,爲什麼呢?謝謝!爲什麼我不能覆蓋`Array`的原型(`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>