The source code of function and its result in JavaScript

In JavaScript, you can write the name of a function without parentheses after it. In this case, we will see not the result of the function, but its source code.

Let's try. Let's say we have a function like this:

function func() { return '!'; }

Let's call this function by writing its name and parentheses. In this case, we will see the result of the function work:

function func() { return '!'; } console.log(func()); // shows '!'

Now let's try to omit the parentheses after the function name. In this case, we will see the source code of our function:

function func() { return '!'; } console.log(func); // we'll see the function code

Run the above code for yourself and make sure that the source code of the function is printed to the console.