Skip to content

eles.slice(start?, end?)

eles.slice — Collection > Iteration and aggregation. Cytoscape.js signatures, parameters and return contract.

eles.slice — Collection › Iteration and aggregation

Preview · Collection › Iteration and aggregation

Read in the complete API reference · All API members

// A sub-range of the collection, with Array#slice semantics (negative indices count from the end)
eles.slice(start?: number, end?: number): Collection<NodeData, EdgeData, Data>

A sub-range of the collection, with Array#slice semantics (negative indices count from the end).

Parameters
NameDescription
start: number?Default: 0

first index, inclusive

end: number?Default: this.length

last index, exclusive

Returns Collection<NodeData, EdgeData, Data>

the sub-range as a new collection

Example

console.log(eles.slice().map(ele => ele.id())); // ["a","b","c","ab","bc"]

Example graph and handle setup