How to retrieve the collection of content types from the SharePoint sub site? There is a property available in SP.Web (SP.js) object to retrieve the collection of content types from parent site and the current site.
The below link redirects you to the property, which helps in retrieving the collection of available content types,
Property Name: SP.Web.availableContentTypes property (sp.js)
The below code supports the SharePoint Online and SharePoint 2013 plus
The code returns the Content type name and its id.