I am going through some code left behind by some long-gone developers and came across this:
Function.prototype.binding = function ()
{
if(arguments.length < 2 && typeof arguments[0] == "undefined") return this;
var __method = this, args = jQuery.makeArray(arguments), object = args.shift();
return function()
{ return __method.apply(object, args.concat(jQuery.makeArray(arguments))); };
};
and it is referenced elsewhere in a couple of places, this DataTables callback function is representitive:
"fnRowCallback": function (nRow, aData, iDisplayIndex)
{
nRow = this.options.fnRowCallback(nRow, aData, iDisplayIndex);
return nRow;
}.binding(this),
I think that what this is accomplishing is to set the this context in the function to the object passed into the .binding; is that correct? And is this way of doing that considered a good practice?
Thanks, Matthew