I have an object from which I call a function. Instead of the value it returns the function itself. This might be a duplicate but I could not find a proper solution. So any buzzword for this matter would be highly appreciated.
var w = window,
d = document,
e = d.documentElement,
g = d.getElementsByTagName('body')[0];
var asd = {
getWindowWidth: function() {
var x = w.innerWidth || e.clientWidth || g.clientWidth;
return x;
},
getWindowHeight: function() {
var x = (function() {
return w.innerWidth || e.clientWidth || g.clientWidth;
})();
return x;
},
init: function() {
console.log("init fired");
console.log(this.getWindowWidth);
console.log(this.getWindowHeight);
console.log(typeof(this.getWindowHeight));
}
}
asd.init();
Thank you in advance for your support.
console.log(this.getWindowWidth);returns the functionconsole.log(this.getWindowWidth());evaluates it and returns the result if thats what you asking (which is not very clear).()after a pointer to a function to actually call it.