Код: Выделить всё
EventSource.prototype.constructor = function(url, config) {
EventSource(url, config);
console.log("intercepted");
}
< /code>
Чтобы переопределить конструктор. Это не работает. Но следующее работает: < /p>
EventSource.prototype.sayHi = () => alert("Hi");
new EventSource("my-data").sayHi()
Подробнее здесь: https://stackoverflow.com/questions/796 ... javascript