I need your help.
I have 2 functions:
addMoveListeners: function(e) {
e = e || window.event;
// Binging context to function move
moveListener = MYAPP.move.bind(e.target.parentElement);
//
if (e.target.classList.contains('move')){
document.addEventListener('mousemove', moveListener, false);
document.addEventListener('mouseup', MYAPP.removeListener, false);
}
resizeListener = MYAPP.resize.bind(e.target.parentElement);
if (e.target.classList.contains('resize')){
document.addEventListener('mousemove', resizeListener, false);
document.addEventListener('mouseup', MYAPP.removeListener, false);
}
return false;
},
and this:
removeListener: function(e){
e = e || window.event;
//Here I want get element from function
console.dir(resizeListener);
// Function stores it in [[BoundThis]]
document.removeEventListener('mousemove', resizeListener, false);
document.removeEventListener('mouseup', MYAPP.removeListener, false);
document.removeEventListener('mousemove', moveListener, false);
document.removeEventListener('mouseup', MYAPP.moveListener, false);
},
How can I get property [[BoundThis]] from function resizeListener without execution.
You cannot. [[BoundThis]] is an internal property of bound function objects. It is not programmatically accessible. You might be able to view it with inspection of the object via console, but to use it in your program logic you will need to write your own version of bind that exposes this value as a property.
The bind() method creates a new function that, when called, has its this keyword set to the provided value, with a given sequence of arguments preceding any provided when the new function is called.
We use the Bind() method to call a function with the this value, this keyword refers to the same object which is currently selected . In other words, bind() method allows us to easily set which object will be bound by the this keyword when a function or method is invoked.
You cannot. [[BoundThis]]
is an internal property of bound function objects. It is not programmatically accessible.
You might be able to view it with inspection of the object via console, but to use it in your program logic you will need to write your own version of bind
that exposes this value as a property.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With