Array object's properties and methods

The Array object's properties and methods are described below:

NN: Netscape, IE: Internet Explorer

Properties

Syntax: object.property_name

PropertyDescriptionNNIE 
constructorContains the function that created an object's prototype44
lengthReturns the number of elements in the array34
prototypeAllows you to add properties to an array34

Methods

Syntax: object.method_name()

MethodDescriptionNNIE
concat()Joins two or more arrays and returns a new array44
join(delimiter)Puts all the elements of an array into a string separated by a specified delimiter (comma is default)34
pop()Removes and returns the last element of an array45.5
push("element1","element2")Adds one or more elements to the end of an array and returns the new length45.5
reverse()Reverses the order of the elements in an array34
shift()Removes and returns the first element of an array45.5
slice(begin[,end])Creates a new array from a selected section of an existing array44
sort()Sorts the elements of an array34
splice(index,howmany[,el1,el2])Adds and/or removes elements of an array45.5
toSource()Returns a string that represents the source code of the array4.064
toString()Returns a string that represents the specified array and its elements34
unshift("element1","element2")Adds one or more elements to the beginning of an array and returns the new length45.5
valueOf()Returns the primitive value of an array43
發佈了56 篇原創文章 · 獲贊 0 · 訪問量 8萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章