E
E
Emptyform2016-08-23 11:11:32
Node.js
Emptyform, 2016-08-23 11:11:32

Why doesn't this example work (function substitution)?

Hey all!
The code:

var emit = server.emit;

/* Вариант 1 - работает */
server.emit = function(event) {
    console.log('блабла');
    return emit.apply(server, arguments);
};

/* Вариант 2 - НЕ работает */
server.emit = event => {
    console.log('блабла'); // <-- это работает
    return emit.apply(server, arguments); // <-- здесь не работает
};

Option 2 does not work - the client does not receive a response, falls off on a timeout.
Why doesn't option 2 work?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question