I want to run a function within an object on click. In the object's init method, I bind a click to "runBFS".
I use bind(this) to traversal so I can pass in the context of the object and not lose it to the window.
var api = {},
api.init = function () {
document.getElementById("runBFS").addEventListener(
"click",
this.traversal.bind(this),
false
);
}
I need to pass in a boolean value on click (traverseNodesBool) but don't know how to pass it in when using bind()
api.traversal = function (e, traverseNodesBool) {
How do I do this?