Skip to content

eles.map(fn, thisArg?)

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

eles.map — Collection › Iteration and aggregation

Preview · Collection › Iteration and aggregation

Read in the complete API reference · All API members

// Map each element through fn into a plain array
eles.map<T>(fn: ( ele: Collection<NodeData, EdgeData, Data>, i: number, eles: Collection<NodeData, EdgeData, Data>, ) => T, thisArg?: unknown): T[]

Map each element through fn into a plain array.

Parameters
NameDescription
fn: ( ele: Collection<NodeData, EdgeData, Data>, i: number, eles: Collection<NodeData, EdgeData, Data>, ) => T

( ele, i, eles)

thisArg: unknown?

optional receiver for the callback

Returns T[]

an array of the results

Example

console.log(cy.nodes().map(node => node.id())); // ['a', 'b', 'c']

Example graph and handle setup