In this video, we are going to learn how to run Node.js functions.
So in the previous video we are running the console.log operation and we can run the node command with
passing this index file.
So in this video, we are going to create methods and see how these methods in our Node.js applications.
In order to do that, let me create a function in here.
It will be the local function.
And we don't have any parameter and we are using the anonymous function structure.
So basically I'm going to console.log inside of this logger method.
So now as you can see that we have two times log operation.
This is the first line of our indexes and we have a method and inside of the method we have another
log operation.
So that means we have added the other logger function.
Now we can run the node command again.
So in order to do that, please open a terminal, go to section 18, go to lecture folder.
And now I'm going to run, not index.
So that means we are in this folder and we are running node index command to run this index file which
just hit enter.
And as you can see, that response only comes with the first line of code.
So that means the only one time our log operation works.
Why logger function not execute and not write this log?
Because we didn't call it.
So in order to call this function, we need to come here and we basically write the method information
with passing the parameters.
In our case, we don't have any parameter, but we should provide these brackets.
So with this line of code, we basically invoke this method to run the additional look.
So after save this index file, we can run, not index again.
And if you hit enter.
This time you can see that we can execute logger function with invoking into index this file and we
also see the second look which comes from the local function because this time we have invoked the local
function in our index file because note command only runs if there is a calling code into JS file.
So let's develop a little bit more.
So I'm going to write some additional code, which is the anonymous function.
Let me copy paste and I will explain after that.
So instead of creating any method and calling this method, we can directly write method and invoke
method instantly with this format, which is the anonymous function.
So we can use anonymous function in order to imitate execute our index file.
So if we run not index again, we can see that we have three times log operation and these enormous
function instantly execute inside of the log operation or method body.
So as you can see that we have successfully run Node.js function and understand the node commands.