SharePoint JSOM code to Hide/Remove Ribbon tabs in SharePoint List Forms or Pages

The Ribbon shows certain tabs like 'Edit', 'View', 'Items', 'List' etc., when we are on a list form page or when a List is added to any SharePoint page. In some cases we do not want to show this tabs to the user, which can be hidden by adding JSOM code to remove the unwanted tabs. [More]