Question about calculated properties

So I was trying to set some menu buttons on my page using a few calculated properties. Like so.


var menuButtons = function () {   
    return getButton("Sign-In", "#loginModal", true) + divider + getButton("Register", "#registerModal");

var divider = function (){
    return '<div class="add-divider"></div>';

My result was kind of strange. Take a look.

I found out the problem was the second function. Now, I was able to clear this up by taking a page from lazy instantiation in Swift programming by adding () to the end of either function.

I know why this works in swift. However I only have a guess as to why this was an issue to begin with in Javascript and why this fixed it. It’s only a guess though. My guess is in javascript the () is an initializer and a reference to the return of the functions return. Without it the variable is a pointer to the function itself?

I think whats throwing me off is that the first variable initialized when I passed it to the ajax expression but the second variable did not when I was using it during string concatenation. Is it that references to functions are automatically initialized when passed as an argument to another function? Am I even close to being right?

I know I got it working but its driving me nuts as to why. So, thanks to anyone in advance for taking the time to educate me.

Edit: I think whats throwing me off the most is why did I initially get the response I want but with a description of what the function is? If Its just a reference to the function wouldnt I get just the function description?

So in here, you use the variable divider rather than the function divider() - so the string concatenation is simply converting the function itself to a string, rather than getting a return value.