How to distinguish between SharePoint 2016 and 2019 programmatically

Copper Contributor

I have a common solution for SharePoint 2016 and 2019 Servers. The solution has both client side (JavaScript) and server side (SSOM and CSOM) components. For some modern UI related work, I need to find out if solution is running on 2019 or 2016. Since both have same major version (16), what is the best way to do it?

In script, is it Ok to check if modernThemingEnabled property is available in _spPageContextInfo?

For server side code, is there any feature that I can check in sites or what is the best way?

1 Reply
Can you share some details of what you are looking to achieve?