There is a very easy way to get Entity Type Code by Name like below
var entityTypeCode = Mscrm.EntityPropUtil.EntityTypeName2CodeMap[“lead”];
this will be really helpful when you try opening a CRM form or window. I have tested this in both CRM 2015 and 2016 which worked as charm.
It’s a very useful solution but… the use of Mscrm namespace is not supported by Microsoft.