How to check Magento version in Magento 2

You can easily get Magento 2 version in the code using the following constant:

This interface is located in vendor/magento/framework/AppInterface.php file.
For more information you can check this class: \Magento\Framework\App\ProductMetadata
Also, as usual, the version is being displayed in the footer in the admin area.