vexi.js.Array - Array Object

The standard js array.

Arrays can be created as literals in vexiscript using [] which creates a new empty array.

Arrays can be initialized with contents in vexiscript using [i1, i2,... in].

Properties

Property Type Description

length

Number

The length of an array.

Methods

Method Returns Description

concat(a1, ...an)

Array

Returns a new array containing the elements from the array object followed by the elements from each of the arguments.

copy()

Array

Returns a shallow copy of the array.

join([separator])

String

Returns the array's values concatenated into a single string, with each value separated by the separator string.

If ‘separator’ is omitted, then it defaults to "," as the separator string.

pop()

varies

Removes the last element of the array and returns it. If the array is currently empty, then it returns null.

push(v1, ...vn)

Number

Adds the specified values to the end of the current array and returns the new size of the array.

reverse()

Array

Reverses the order of the elements in the current array and returns the array.

shift()

varies

Removes the first element of the array and returns it. If the array is currently empty, then it returns null.

slice([start, end])

Array

Returns a new array which contains a copy of the section of the current array between ‘start’ and ‘end - 1’, inclusive.

If either argument is less than 0, then the argument is treated as the number of slots counted backwards from the end of the array. If ‘start’ is omitted, it defaults to the start of the array; if ‘end’ is omitted, it defaults to the array's length. If ‘start’ is greater than ‘end’, the function returns an empty array.

sort([compareFunction])

Array

Sorts the contents of the current array and returns it.

If ‘compareFunction’ is specified, then the given comparison function (which must take 2 arguments) will be used to do the sorting. If ‘compareFunction’ is omitted, then the values will be sorted alphabetically by their string values.

splice([start, deleteCount, v1, ...vn])

Number

Removes the array elements from ‘start’ to ‘start + deleteCount’ from the array, and replaces them with the specified values. Returns a new array containing the deleted values.

If ‘start’ is less than 0, then the argument is treated as the number of slots counted backwards from the end of the array. If ‘start’ is omitted, it defaults to the start of the array; if ‘deleteCount’ is omitted, it defaults to 0. If no values are specified, then no new items are inserted into the array.

toString()

String

Returns array.join().

unshift(v1, ...vn)

Number

Inserts the specified values at the beginning of the array. Returns the new size of the array.

 


Copyright © 2011 The Vexi Project (vexi.sourceforge.net)