Window property on function | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Window property on function

Why does a function appear when alert the heigh/width property of the widow? Function: function (e,f){var g=arguments.length&&(c||"boolean"!=typeof e),h=c||(e===!0||f===!0?"margin":"border");return T(this,function(b,c,e){var f;return r.isWindow(b)?0===d.indexOf("outer")?b["inner"+a]:b.document.documentElement["client"+a]:9===b.nodeType?(f=b.documentElement,Math.max(b.body["scroll"+a],f["scroll"+a],b.body["offset"+a],f["offset"+a],f["client"+a])):void 0===e?r.css(b,c,h):r.style(b,c,e,h)},b,g?e:void 0,g)} h

15th Jan 2018, 1:44 PM
David Wesley
David Wesley - avatar
4 Answers
+ 4
/* The reason is that 'height' is a function, so assigning it as is to a variable will store the reference of the function itself... to call a function, you need to append a parenthesis pair after its name, so the function is executed, and the returned value is stored in the variable ^^ */ function myfunction() { return 42; } var a = myfunction; alert(a); // show the function source code, because a hold the function itself, and default cast to string will show its code var b = myfunction(); alert(b); // output 42 // but with 'a', since you've assigned to it a function reference, you can now do: var c = a(); alert(c); // output 42 // or shorter: alert(a()); // output 42
15th Jan 2018, 2:44 PM
visph
visph - avatar
+ 3
@visph Thank you...
15th Jan 2018, 2:48 PM
David Wesley
David Wesley - avatar
15th Jan 2018, 1:48 PM
David Wesley
David Wesley - avatar
15th Jan 2018, 2:35 PM
John Wells
John Wells - avatar