Skip to content

eles.first()

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

eles.first — Collection › Iteration and aggregation

Preview · Collection › Iteration and aggregation

Read in the complete API reference · All API members

// The first element, as a length-1 collection
eles.first(): Collection<NodeData, EdgeData, Data>

The first element, as a length-1 collection.

Returns Collection<NodeData, EdgeData, Data>

the first element, or an empty collection

Example

console.log(eles.first().map(ele => ele.id())); // ["a"]

Example graph and handle setup