How to access the current mode from modeBarButtonsToAdd


I have added a button to the modebar to change the current the mode of the graph.

            displaylogo: false,
            responsive: true,
                name: 'Trace markers toggler',        
                icon: icon1,        
                click: function(graphContainer) {

                    Plotly.restyle(graphContainer, {mode: 'lines+markers'})

I would like to toggle the mode from lines to lines+markers and viceversa, but I don’t know how to access the current mode. Any help?