0

What is happening in both the cases and why is the output changing when the curly braces are placed on a new line. I'm not aware of this concept. Please explain.

Code Segment 1:

(function(){
    return {
        a : 1
    }
})();

# Output
{a: 1}

Code Segment 2:

(function(){
    return 
    {
        a : 1
    }
})();

# Output 
undefined

Why isn't the object returned in second scenario? I just added a newline character.

Deadpool
  • 2,198
  • 9
  • 22

0 Answers0