I have an array of nodes that will beautifully be populated with obj
s
var nodesArray = [];
var obj = function(nodeSpan){
this.nodeS = nodeSpan;
this.doThings = function(){
console.log(this.nodeS);
};
}
I put lots of obj
's into nodeArray
var newObj = new obj(thisIsASpan) ///trust me that's a span
nodesArray.push(newObj);
//etc
I call a map function on each node adding an event listener.
Array.prototype.map.call(nodesArray, function(obj, index) {
obj.nodeS.addEventListener('click', function(obj, index) {
nodesArray[index].doThings(); ////Throws error in title.
});
});
I click on one of the damn spans.
I get error in title, I then walk to break room, I then have breakdown.