 <p>Assuming that you're not limited by some older JS implementation, you can use <a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object/defineProperty" rel="nofollow">Object.defineProperty</a>.</p>