JavaScript Array Object PropertiesMethod

xiaoxiao2021-03-06  14

Array.LENTH attribute

.concat method

For object link references, copy its value for characters or strings

.join method

All elements separated by the specified separator

.pop and .push

POP removes the last element from the array and returns the element if the array is empty, then returns undefined

The PUSH method adds the new elements to the order of appearance. If one of the parameters is an array, the array will be added to an array as a single element. If you want to merge elements from two or more arrays, use the Concat method

POP and PUSH are different from the same name method in C, which can be considered to implement the "queue" structure.

.shift and .unshift

The SHIFT method removes the first element in the array and returns it, and the unshift method inserts these elements into the beginning of an array so that they are arranged in the order in the parameter table.

Shift and unshift methods can be used to implement the "stack" structure.

.reverse method,

The .slice method is the same as the array of Python "Pixabay" function.

.sort method

Returns the sorted Array object, the default element will be arranged in ascending order in the ASCII character sequence

.SPLICE method

The splice method modifies the array by removing the element starting from the Start position and inserts a new element. Return value is a new Array object consisting of the removed element

.Tolocalstring and Tosting method

The TOLOCALSTRING method returns a value in the form of a string value, which is suitable for the current area setting of the host environment.

TOSTRING method Returns a string of the object

.valueof method

Returns the primitive value of the specified object.

转载请注明原文地址:https://www.9cbs.com/read-47259.html

New Post(0)