define property on object constructor in JavaScript

JavaScript

🤖 Code Explanation

The code is defining a class for a person, with name and age properties. It is then making the name property read-only, so that it can't be changed. Finally, it creates a new person object and tries to change the name property, which throws an error.

Download SpellBox today