SharePoint: Get current list view using ECMA Script

SharePoint 2010:
The current listId can be retrieved using _spPageContextInfo.pageListId and this can be used to get the current view of the list. _spPageContextInfo doesn't contain any information about the view. However, there is OOB object named g_ctxDict which can give view information as can be seen from below code:
var listId = _spPageContextInfo.pageListId;
var viewId;
for (var ctxKey in g_ctxDict) {
    var curCtx = g_ctxDict[ctxKey];
    if (curCtx.listName.toLowerCase() == listId.toLowerCase()) {
        viewId = curCtx.view;
        break;
    }
}
SharePoint 2013 
SharePoint 2013 makes it easy to get view information using:
var viewId = SP.ListOperation.ViewOperation.getSelectedView();
You can visit my codeplex project Export List Version History for a complete working example.