Below is the Code for Fetching Name of an Entity Using JavaScript In mscrm , Which can be used for many purposes  Like if you want to popup an new entity form ( you can create a generic function )

 var entityName = Xrm.Page.data.entity.getEntityName();

// Pop Up example

 var id = Xrm.Page.data.entity.getId();
            var entityName = Xrm.Page.data.entity.getEntityName();
            Xrm.Utility.openEntityForm(entityName, id);


Hope This Helps You Thanks.
SOURCE : JUST2CODE.IN Subscribe to our YouTube channel : https://www.youtube.com/user/TheRussell2012