I think you are mixing the meanings of architecture and OS version.
OS version you are looking for is actually a Windows Edition and it has nothing to do with CPU architecture.
As for your question, I think you are looking for this:
using System.Management;
var name = (from x in new ManagementObjectSearcher("SELECT * FROM Win32_OperatingSystem").Get().OfType<ManagementObject>()
select x.GetPropertyValue("Caption")).FirstOrDefault();
return name != null ? name.ToString() : "Unknown";
taken from here
Regarding JavaScript I'm pretty sure that at least for now there is no way to know the edition.