This has been asked regarding Windows, but not macOS.
(Yes, there's a comment on that question regarding macOS, but it's a comment and not an answer, so it's likely to be overlooked, and it's on a question about Windows, and to top it all off it's wrong.)
So, for sake of making (the correct version of) this information easy to find:
Where does VS Code store unsaved files on macOS?