// person-js.js // Personクラス定義 function Person(name, age, job) { this.name = name; this.age = age; this.job = job; this.observers = []; // オブザーバを追加 this.addObservers = function(func) { this.observers.push(func); }; // 変更が有った際にオブザーバに通知 this.notifyObservers = (propertyName, newValue) => { for (let i = 0; i < this.observers.length; i++) { this.observers[i].apply(this, [propertyName, newValue]); } };