{hero}

slice()

版本:DataTables 1.10.15

创建 API 实例的独立副本。

说明

DataTables API 对象“类数组”,并继承了许多与 Javascript 数组相同的功能。 slice() 方法是其中之一。它提供了创建实例的独立副本的功能,以便对其进行操作而不影响其原始副本。

此方法是 Javascript Array.prototype.slice 方法的代理,并专门针对 DataTables API 作为实用方法提供。有关原始方法的详细信息,请参阅 Mozilla MDN 对 slice 的文档

类型

函数 slice()

说明

创建 API 实例的独立副本。

返回值

API 实例

示例

修改实例的副本而不影响其原始副本。

1
2
3
4
5
6
7
8
9
var table = new DataTable('#myTable');
 
var data = table.column(0).data();
 
var data2 = data.slice();
 
data2.push('Fini');
 
// `data` is unaffected

Comments (0)

No comments posted for this page yet. Be the first to contribute!

Post new comment

Contributions in the form of tips, code snippets and suggestions for the above material are very welcome. To post a comment, please use the form below. Text is formatted by Markdown.

To post comments, please sign in to your DataTables account, or register:

Any questions posted here will be deleted without being published.
Please post questions in the Forums. Comments are moderated.