I am creating **SharePoint hosted app.** I have to develope an app such that it should work in all edition of
SharePoint and its features will vary from edition to edition.
Now I have couple of questions

1. Can we write pre-requests for SharePoint app by using Javascript as we add it in AppManifest.xml?
2. Can we detect edition of the SharePoint used where the app will be install?

We can have edition of SharePoint by C# code 

http://msdn.microsoft.com/en-us/library/jj659075.aspx#SP15DetectSKU...

But I am working on SharePoint hosted app so can we have the same by some javascript code? 
Please provide some reference links if possible.