JavaScript中数组对象的属性是什么?
Array对象使您可以将多个值存储在单个变量中。它存储相同类型元素的固定大小的顺序集合。
以下是Array对象的属性列表-
属性和说明
返回对创建对象的数组函数的引用。
该属性表示字符串中匹配项的从零开始的索引。
此属性仅存在于由正则表达式匹配创建的数组中。
反映数组中元素的数量。
prototype属性允许您向对象添加属性和方法。
示例
让我们看一个原型属性的例子
<html>
<head>
<title>JavaScript Array Object</title>
<script>
function book(title, author){
this.title = title;
this.author = author;
}
</script>
</head>
<body>
<script>
var myBook = new book("Java", "John");
book.prototype.price = null;
myBook.price = 300;
document.write("Book title is : " + myBook.title + "<br>");
document.write("Book author is : " + myBook.author + "<br>");
document.write("Book price is : " + myBook.price + "<br>");
</script>
</body>
</html>输出结果
Book title is : Java Book author is : John Book price is : 300
热门推荐
1 狗狗技能训练
5 如何训练狗狗笑
6 狗狗训练排便
9 狗狗响片训练
10 如何训练狗狗不捡食
11 狗狗尿训练
12 怎么训练狗狗找东西
13 狗狗训练站立
14 狗狗训练飞盘
15 鞍山狗狗训练
16 怎样训练泰迪狗狗谢谢
17 狗狗外出训练
18 怎么训练金毛狗狗大小便