toArray()
Create a native Javascript array object from an API instance.
Description
The DataTables API object provides a lot of the methods that you would expect to find in a native Javascript array and generally acts a lot like an array, but there are times when you want to work directly with a Javascript array rather than a DataTables API instance. This method can be used to create a native Javascript array which contains the same items as contained in the API instance's result set.
This method makes use of the fact that DataTables API objects are "array like", in that they inherit a lot of the abilities and methods of the Javascript Array
type.
Type
function toArray()
- Description:
Create a native Javascript array from an API instance.
- Returns:
Javascript array which contains the values from the API instance's result set.
Example
Get a plain array of data from a column:
var table = new DataTable('#myTable');
var plainArray = table
.column(0)
.data()
.toArray();