Ok so, I am trying to access a property and I am having issues with it.
The issue seems to be while accessing this.threshhold
. In the example below, I expected the alert to display 100
, but I am getting undefined
.
I understand that the object has not yet been created and I assume that neither the object nor the property exist yet(?) so the object cannot not be accessed for that obvious reason.
Am I approaching this wrongly? Can this be done? If not; is there any other clean/proper way to do this?
Hopefully, I have been clear enough.
https://jsfiddle.net/fq58vz1f/
var helpers = {
throttle: function(fn, threshhold) {
return function() {
alert(threshhold);
}
}
};
var header = {
threshhold: 100,
scroll: helpers.throttle(function() {
// stuff
}, this.threshhold)
};
header.scroll();