Just a guess, but it sounds like you're making some kind of app or tool for yourself, and you'd like to keep a persistent state. For this, you can use the Web Storage API.
window.localStorage.setItem('names', JSON.stringify(nameData));
nameData = JSON.parse(window.localStorage.getItem('names'));