{hero}

slice()

Since: DataTables 1.10.15

Create an independent copy of the API instance.

Description

The DataTables API object is "array like" and inherits many of the same characteristics as a Javascript array. The slice() method is one of these. It provides the ability to create an independent copy of the instance so it can be manipulated without affecting the original.

This method is a proxy for the Javascript Array.prototype.slice 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 slice.

Type

function slice()

Description:

Create an independent copy of the API instance.

Returns:

API instance

Example

Modify a copy of an instance without affecting the original.:

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

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

var data2 = data.slice();

data2.push('Fini');

// `data` is unaffected