{hero}

shift()

Since: DataTables 1.10

Remove the first item from an API instance's result set.

Description

Just as with Javascript arrays, since the DataTables API object is "array like", items can be removed from a result set using this method. Shifting a result, shifts the item off the start of the result set. The API instance's result set is reduced in length by 1 and the item that was removed is returned from the function call. pop() can be used to perform the same action, but at the end of the array, if required.

This method is a proxy for the Javascript Array.prototype.shift method and is provided as a utility method for the DataTables API. For more information about the original method, please refer to the Mozilla MDN documentation for shift.

Type

function shift()

Description:

Remove the first item from an API instance's result set.

Returns:

Any

Item removed form the result set (was previously the first item in the result set).

Example

Get the last item from a column.:

var table = new DataTable('#myTable');

var data = table.column(0).data();

var firstItem = data.shift();

alert('First item in the result set was: ' + firstItem);