https://en.wikipedia.org/wiki/The_Legend_of_Zelda_(video_game)
More than a year later, North America and Europe received releases on the Nintendo Entertainment System in cartridge format, making the game the first home console title to include an internal battery for saving data.
which is why it works for that as the hardware/flash is emulated by the emulator.
some mame games support hiscore saving via a file which details the part of memory which contains the scores etc so the emulator can dump/reload that part. I don't know if any of the nes emulators have any functionality like this.