Contents

toArray()

Converts the JavaScript value to an array.

Declaration

func toArray() -> [Any]!

Return Value

The array representation of the value.

Discussion

If the value is a JavaScript object, this method reads the object’s length property as an unsigned integer, creates an NSArray object of the corresponding size, and recursively copies and converts any properties corresponding to indices within the array bounds. JavaScript converts each element to a native object using the rules listed in Convert Between JavaScript and Native Types.

This method returns nil if the JavaScript value is null or undefined, and throws a JavaScript TypeError if the value is not a JavaScript object.

See Also

Reading and Converting JavaScript Values