Canon 50mm f/1.8 STM vs Canon 50mm f/1.8 II?
Go to The-digital-Picture.com, search for Canon 50mm f1.8 STM review, click on "Image Quality". This web page will let you see the images of a resolution chart as taken with the selected lens. You can choose what camera body, the focal length (if it's a zoom lens), the f-stop, and a different image will be shown. You can choose another lens on the right side to compare. In this case you can choose the Canon 50mm f1.8 II. Move your mouse pointer on top of the little arrow at the top of the image and it will switch to the image taken by the second lens. Move the mouse away, it will show the first image. I find this lens comparison site very useful.
From the sites comparison between the 2 50mm lens, the STM lens produces slightly better results from f1.8 up to f8 (especially the mid-frame part of the images), when both lenses become equal. So I think they may not be optically the same.