I have this class created in pure JavaScript:
var MapInteraction = function () {
return {
handleNavigation: handleNavigation,
handleMapDrawing: handleMapDrawing,
handleMapData: handleMapData
};
//controls map interactions
function handleNavigation() {
//some code
}
function handleMapDrawing() {
//some code
}
function handleMapData() {
//some code
}
};
Here is how I creaet instance of the class:
var mapInteraction = new MapInteraction();
at some point, I want to iterate on MapInteraction functions and to get the instance of each member. Here how I do it:
mapInteraction.forEach((interaction, interactionType) => {
if (interaction instanceof interactionToEnable)
{
//do something
}
});
But on the row above I get this error(I understand that I can't use foreach because it suitable only for arrays):
Uncaught TypeError: mapInteraction.forEach is not a function
My question is how can iterate on MapInteraction functions and to get an instance of each member?
Aucun commentaire:
Enregistrer un commentaire