I know probably what you are thinking , we do we need to specify semicolon in my code explicitly? I am getting the right output always without specifying a semicolon also. Well it’s not always right.
Let me give an example the importance of semicolon. Consider the below code
What will be the output of this function? everyone might think output will be
But it’s not right , the output is undefined .
When you put object literal in the next line of return statement , syntax parser will do a automatic semicolon insertion after the keyword return and jump out of the function.
Now you will get the output of