属性constructor:返回对创建此对象的数组函数的引用。constructor属性是返回对创建此对象的数组函数的引用var test=new Array();if (test.constructor==Array){document.write("This is an Array");}if (test.constructor==Boolean){document.write("This is a Boolean");}if (test.constructor==Date){document.write("This is a Date");}if (test.constructor==String){document.write("This is a String");}</script>输出结果为:This is an Arraylength:设置或返回数组中元素的数目。length属性是设置或返回数组中的元素的数目var arr = new Array(3)arr[0] = "John"arr[1] = "Andy"arr[2] = "Wendy"document.write("Original length: " + arr.length)document.write("<br />")arr.length=5document.write("New length: " + arr.length)</script>输出结果为:Original length: 3New length: 5prototype:使您有能力向对象添加属性和方法。prototype属性是相对想添加属性和方法function employee(name,job,born){this.name=name;this.job=job;this.born=born;}var bill=new employee("Bill Gates","Engineer",1985);employee.prototype.salary=null;bill.salary=20000;document.write(bill.salary);</script>输出结果为:20000方法concat():连接两个或更多的数组,并返回结果。concat()方法是连接两个或者多个的数组,并返回结果var a = [1,2,3];document.write(a.concat(4,5));</script>输出结果为:1,2,3,4,5join():把数组的所有元素放入一个字符串。前端培训元素通过指定的分隔符进行分隔。join()方法是把数组的所有元素放入一个字符串,通过指定的分隔符进行分隔var arr = new Array(3)arr[0] = "George"arr[1] = "John"arr[2] = "Thomas"document.write(arr.join())</script>输出结果为:George,John,Thomaspop():删除并返回数组的最后一个元素pop()方法是删除并返回数组的最后一个元素var arr = new Array(3)arr[0] = "George"arr[1] = "John"arr[2] = "Thomas"document.write(arr)document.write("<br />")document.write(arr.pop())document.write("<br />")document.write(arr)</script>输出结果为:George,John,ThomasThomasGeorge,Johnpush():向数组的末尾添加一个或更多元素,并返回新的长度。push()方法是向数组的末尾添加一个或更多元素,并返回新的长度。var arr = new Array(3)arr[0] = "George"arr[1] = "John"arr[2] = "Thomas"document.write(arr + "<br />")document.write(arr.push("James") + "<br />")document.write(arr)</script>输出结果为:George,John,Thomas4George,John,Thomas,Jamesreverse():颠倒数组中元素的顺序。reverse()方式是颠倒数组中元素的顺序var arr = new Array(3)arr[0] = "George"arr[1] = "John"arr[2] = "Thomas"document.write(arr + "<br />")document.write(arr.reverse())</script>输出结果为:George,John,ThomasThomas,John,Georgeshift():删除并返回数组的第一个元素shift()方法是删除并放回数组的第一个元素var arr = new Array(3)arr[0] = "George"arr[1] = "John"arr[2] = "Thomas"document.write(arr + "<br />")document.write(arr.shift() + "<br />")document.write(arr)</script>输出结果为:George,John,ThomasGeorgeJohn,Thomasslice():从某个已有的数组返回选定的元素slice()方法是从某个已有的数组返回选定的元素var arr = new Array(3)arr[0] = "George"arr[1] = "John"arr[2] = "Thomas"document.write(arr + "<br />")document.write(arr.slice(1) + "<br />")document.write(arr)</script>输出结果:George,John,ThomasJohn,ThomasGeorge,John,Thomassort():对数组的元素进行排序sort()方式是对数组的元素进行排序var arr = new Array(6)arr[0] = "George"arr[1] = "John"arr[2] = "Thomas"arr[3] = "James"arr[4] = "Adrew"arr[5] = "Martin"document.write(arr + "<br />")document.write(arr.sort())</script>输出结果为:George,John,Thomas,James,Adrew,MartinAdrew,George,James,John,Martin,Thomassplice():删除元素,冰箱数组添加新元素splice()方法是删除元素,并向数组添加新元素举例:创建一个新数组,并将其添加一个元素var arr = new Array(6)arr[0] = "George"arr[1] = "John"arr[2] = "Thomas"arr[3] = "James"arr[4] = "Adrew"arr[5] = "Martin"document.write(arr + "<br />")arr.splice(2,0,"William")document.write(arr + "<br />")</script>输出结果为:George,John,Thomas,James,Adrew,MartinGeorge,John,William,Thomas,James,Adrew,Martin举例:删除位于i[2]的元素,并添加一个新的元素来替换被删除的元素var arr = new Array(6)arr[0] = "George"arr[1] = "John"arr[2] = "Thomas"arr[3] = "James"arr[4] = "Adrew"arr[5] = "Martin"document.write(arr + "<br />")arr.splice(2,1,"William")document.write(arr)</script>输出结果为:George,John,Thomas,James,Adrew,MartinGeorge,John,William,James,Adrew,MartintoSource():返回该对象的源代码toSource()方法是返回该对象的源代码function employee(name,job,born){this.name=name;this.job=job;this.born=born;}var bill=new employee("Bill Gates","Engineer",1985);document.write(bill.toSource());</script>输出结果为:({name:"Bill Gates", job:"Engineer", born:1985})toString():把数组转换为字符串,并返回结果toString()方法是把数组转换为字符串,并返回结果var arr = new Array(3)arr[0] = "George"arr[1] = "John"arr[2] = "Thomas"document.write(arr.toString())</script>输出结果为:George,John,ThomastoLocaleString():把数组转换为本地数组,并返回结果toLocaleString()方法把数组转换为本地数组,并返回结果var arr = new Array(3)arr[0] = "George"arr[1] = "John"arr[2] = "Thomas"document.write(arr.toLocaleString())</script>输出结果为:George, John, Thomasunshift():像数组的开头添加一个或者更多的元素,并且返回性的数组长度unshift()方法是像数组的开头添加一个或者更多的元素,并且返回性的数组长度var arr = new Array()arr[0] = "George"arr[1] = "John"arr[2] = "Thomas"document.write(arr + "<br />")document.write(arr.unshift("William") + "<br />")document.write(arr)</script>输出结果:George,John,ThomasWilliam,George,John,ThomasvalueOf():返回数组对象的原始值。valueOf()方法返回数组对象的原始值。语法:arrayObject.valueOf()
