There is piece of code:
var object = {
findById: function(idNumber) {
var data = this.childNodes;
var returnItems = {};
function callback(node) {
if (parseInt(node.id) === idNumber)
returnItems = node;
};
function iterator(node, callback) {
callback(node);
var nodes = node.childNodes;
if (nodes === undefined) {
return;
};
for (var i = 0; i < nodes.length; i++) {
var iterNode = nodes[i];
iterator(iterNode, callback);
};
};
function bind(func, context) {
return function() { // (*)
return func.apply(context, arguments);
};
};
for (var i = data.length - 1; i >= 0; i--) {
iterator(data[i], callback);
};
return returnItems;
},
}
How to import context in to iterator and callback function? if I put console.log(this) into function iterator() - this will be 'window', but not my object. Also it shouldn't be this.callback this.iterator etc. As I understand it should be like call/apply or bind. How do it?