Recently in my project i was required to get the entity type code of entity. A little bit of searching and I could find multiple ways to get them in jscript.
However the main problems were:
1. they were working only on entity forms
2. you would have to make a metadata call to get the objecttypecode
To overcome both of this in CRM 2013, you could use the Xrm.Internal namespace. Please note that this is not a documented api by Microsoft to be used by the end users.
However it exposes some utility functions which you can use. Of them i used the Xrm.Internal.getEntityCode(“<entitylogicalname>”) method.
For e.g – Xrm.Internal.getEntityCode(“account”) would return you 1.
And this is not restricted to Form only. You can use it anywhere in the context of CRM.
To explore other methods of this namespace, refer to this link –
Hope this helps!