How to check what the latest active view was in tab layout?

In a tab layout I have 5 tabs. When I click on #view-4 I would like to check witch view that was active before I do so.

Lets say I open view-1 or view-2 and look at some stuff there, then when I click on view-4 I need to know witch of the views that I had opened.

Thanks.

store initial active view in some variable:

var activeView = 'home';

$('.view#catalog').on('tab:show', () => {
  // do something based on previously active view
  console.log(activeView);
  // reassign in the end
  activeView = 'catalog';
});

Thanks Vladimir. Just what I did to make it work and set the variable to be the present view when tab on show. Works greate.