I am trying to combine socket.io with backbone.js.
I have found a piece of starting code online, which I understand 99%. The only problem I have is understanding the following line:
In the code below the only item added to the default model or collection is this.ctx, which is optional. It is used to provide a
context for the operation and should be defined upon initializing a
Backbone model or collection.
What is ment by contect. Is it used to pass variables ?? Is it used to pass a callback ??
The complete code can de found here: Backbone.js and socket.io
I have tried to figure this out for myself for quite some time now, and I can make the code work whilst working my way around it. But I am curious what the writer actually intended.
Generally in JS a context refers to the object that
thisrefers to within a function like an event handler. For instance, assume the below made-up event registration function accepts a callback as its third argument and a context as its fourth argument, and you call it like this: