Pregunta de entrevista de Pinterest

The coding exercise consisted of creating a JavaScript class called Model that would expose the following methods: get, set, has, on, trigger. The class signature would be something like the following: const Woof = new Model({id:133, type: 'dog', name:'Spot' }); The has method would take a property name and check if the model has that particular property, return true or false. The get method would take a property name and return it's value if it exists. Return null if not. The set method would take a property name and a value and set that property's value if the property exists. The on method would allow for the addition of an event to the class and a callback function. The trigger method would allow the "triggering" of a particular event and pass any number of parameters to the callback function. You can use ES5 or ES6 syntax.